用python开发web,一步一个脚印
3.初步MVC的server
5.简单的2种爬虫(静态和动态),以及一个jsonapi的小例子Spider
6.用Flask改写的server_flask
包含的功能:
1.用户管理
route_dict = {
'/': route_index,欢迎界面。有1个login链接
'/login': route_login,登陆界面,登陆成功该界面刷新一些信息,不跳转。有2个链接分别去该用户的todo界面和tweet界面,有2个链接分别是数据api
'/register': route_register,注册界面,注册成功该界面刷新一些信息,不跳转。
'/out': route_out,退出登陆
'/messages': route_message,演示表单提交的页面,显示所有message
'/profile': login_required(route_profile),该用户的id name password
'/admin/users': login_required(admin),id为1的admin用户可以看所有用户id name password
'/admin/user/update': login_required(admin_update),id为1的admin用户可以更改所有用户password
}
2.todo
操作
index
界面,分别用http
页面刷新方式和ajax
方式显示。可对todo
进行CRUD
,也可以更改todo
状态。
route_dict = {
'/todo/index': login_required(index),
'/todo/add': login_required(add),
'/todo/edit': login_required(edit),
'/todo/update': login_required(update),
'/todo/delete': login_required(delete),
'/todo/status_switch': login_required(switch),
}
api接口
route_dict = {
'/ajax/todo/index': login_required(index),
'/ajax/todo/add': login_required(add),
'/ajax/todo/delete': login_required(delete),
'/ajax/todo/update': login_required(update),
'/ajax/todo/status_switch': login_required(switch),
}
3.tweet
和comment
操作
index
界面,分别用http
页面刷新方式和ajax
方式显示。可对tweet
和comment
进行CRUD 除了使用ajax
api的comment
不会根据user_id
改变外,http
的tweet
和comment
以及ajax
api的tweet
可以根据user_id
显示,并有用户验证功能 验证规则是:自己只能删除自己的东西(tweet
和comment
)
route_dict = {
'/tweet/index': login_required(index),
'/tweet/delete': login_required(delete),
'/tweet/edit': login_required(edit),
'/tweet/update': login_required(update),
'/tweet/add': login_required(add),
'/tweet/new': login_required(new),
'/comment/add': login_required(comment_add),
'/comment/delete': login_required(comment_delete),
'/comment/edit': login_required(comment_edit),
'/comment/update': login_required(comment_update),
}
api接口
route_dict = {
'/ajax/tweet/index': login_required(index),
'/ajax/tweet/add': login_required(add),
'/ajax/tweet/delete': login_required(delete),
'/ajax/tweet/update': login_required(update),
'/ajax/comment/index': login_required(comment_index),
'/ajax/comment/add': login_required(comment_add),
'/ajax/comment/delete': login_required(comment_delete),
'/ajax/comment/update': login_required(comment_update),
}
4.简单的cookie
和session
功能
- 前端用到了
html
,ajax
和jinja
模板渲染 - 后端未使用任何框架。基于
socket
手工打造以及Flask
版本 - 数据存储有
txt
接口和MongoDB
接口