- 25
- 0
- 约1.66千字
- 约 27页
- 2023-02-01 发布于江苏
- 举报
第2章 信息系统的支撑技术;1、网络应用开发概述、规划设计;重点:编写网络应用程序;课堂导入;;2、浏览器/服务器架构(Browse/Server架构,简称B/S架构);;图2.6.4 登录界面; Sqlite数据库
Sqlite是一个轻量级、跨平台的关系型数据库,具有独立性 零配 置、开放性、占用资源低等特点。基本操作包括创建数据库、连接数据库、创建数据表创建数据记录删除数据记录、查询数据记录、更新数据记录。 Python语言可以通过加载SQLt模块来操作 Sqlite,也可以借助第三方的软件来管理 Sqlite, 如 Sqlite Studio、 Sqlitespy和 Sqliteadmin等。;图2.6.3 “网络聊天机器人”功能图;;(1)导入框架模块。为Web应用程序导入 Flask框架及扩展的模块,以便在程序代码中使用框架提供的功能,其代码如下:
from flask import Flask 导入 Flask框架模块;图2.6.7 URL、路由和视图函数关联图;(4)启动web应用。其代码如下:
if_name_==‘_main_’:
app.run();例1
用 Flask Web框架实现一个在网页中显示文本“这是我的第一个网页程序!”的Web应用,其程序代码(web.py)如下
from flask import Flask
from flask_script import Server, Manager #导入 Flask的服务器管理扩展模块
app Flask( namemanager Manager(app)
server Server(host=0.0.0.0, port=80, threaded=True)
manager.add_command(runserver, server)
@app.route(‘/’)
def index
return 这是我的第一个网页程序!’
If_name_==‘_main_’:
manager.run(;拓展链接;例2
使用FlaskFrom模块实现网络聊天机器人简单对话的功能,其程序代码webrobot如下:;模板文件: index.html
{ extends base. html %)
{ import bootstrap/wtf .html“ as wuf %}
{% block title % } 聊天机器人 { % enblock%}
{% block page_content %}
div class=“header”
hlimg src= “static/robot.png”/ {% if name %} {{% else %} 请说话…{% endif % /hl
/div
{{wtf.quick _form(form)}}
{% endblock %];图2.6.8 网络聊天机器人;;2、应用发布;CGI
CGI是外部应用程序与Web服务器之间的接口标准,它允许Web服务器执行外部程序,并将它们的输出发送给Web浏览器,是Web技术中最重要的技术之一。;思考与练习
根据“网络聊天机器人”功能图(如图2.6.3),尝试完成聊天机器人的其???意一个功能模块。;巩固与提高
1.以你熟悉的信息系统为例,对该系统的硬件、软件、传感与控制以及网络的组成进行分析,并从使用者的角度对其便捷性和安全性进行评价。
2.请选择一种方式,如演示文稿、图示、板书等,向同学讲解2.4或2.5节的内容。要求详略得当,举例恰当,清晰明了。;3.设计一个可以实时监控家庭环境的家庭安防系统。当家中无人时,如果有外来人员进入,该系统能立即报警并通知主人,还具备视频录制等功能。请思考:整个系统需要哪些硬件设备,应用软件要具备哪些功能?;;知识从点滴累积
您可能关注的文档
- 人教版英语八年级下册Unit 2 I'll help to clean up the city parks. SectionB (2a-2e).pptx
- 人教版英语八年级下册Unit 2 I'll help to clean up the city parks.Section A(3a-4c)b.pptx
- 仁爱科普版英语七年级下册Unit 5 Our school life Topic 2 A few students are running around the playground Section C 课件.pptx
- 仁爱科普版英语七年级下册Unit 5 Our school life Topic 2 A few students are running around the playgroundSection D 课件.pptx
- 仁爱科普版英语七年级下册Unit 5 Our school life Topic 3 My school life is very interesting Section C 课件.pptx
- 仁爱科普版英语七年级下册Unit 6 Our local area Topic 1 There is a stuady next to my bedroom Section A 课件.pptx
- 仁爱科普版英语七年级下册Unit 6 Our local area Topic 1 There is a stuady next to my bedroom Section C 课件.pptx
- 仁爱科普版英语七年级下册Unit 6 Our local area Topic 1 There is a stuady next to my bedroom Section D 课件.pptx
- 仁爱科普版英语七年级下册Unit 6 Our local area Topic 1 There is a stuady next to my bedroom1 Section B 课件.pptx
- 仁爱科普版英语七年级下册Unit 6 Our local area Topic 2 My home is in an apartment building Section A 课件.pptx
原创力文档

文档评论(0)