Skip to content

KiwiShow/PythonWeb

Repository files navigation

PythonWeb

用python开发web,一步一个脚印

1.简单的clientserver

2.加强版本的clientserver

3.初步MVC的server

4.简单的sqliteMongoDB数据库的练习MongoDBsqlite

5.简单的2种爬虫(静态和动态),以及一个jsonapi的小例子Spider

6.用Flask改写的server_flask

简单说说初步MVC的server,在文件夹server_normal中。

包含的功能:

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.tweetcomment操作

index界面,分别用http页面刷新方式和ajax方式显示。可对tweetcomment进行CRUD 除了使用ajaxapi的comment不会根据user_id改变外, httptweetcomment以及ajaxapi的tweet可以根据user_id显示,并有用户验证功能 验证规则是:自己只能删除自己的东西(tweetcomment)

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.简单的cookiesession功能

相关技术

  1. 前端用到了htmlajaxjinja模板渲染
  2. 后端未使用任何框架。基于socket手工打造以及Flask版本
  3. 数据存储有txt接口和MongoDB接口

About

用python开发web,一步一个脚印

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published