Flask-实现博客基本功能

来源:互联网 发布:北京优化公司 编辑:程序博客网 时间:2024/04/30 02:42

功能:

新用户注册register(confirm email需要验证邮箱)

用户登陆login

用户登出logout

忘记密码,更改密码(发送邮件,从邮箱中跳转到更改密码页面)

更改用户名

不登录用户只能浏览页面

登陆用户可以发博客,编辑、删除自己以前的博客

页面展示(分页导航)

只查看某人发过的博客

用户查看编辑个人资料


数据库:SQLAlchemy,涉及model,数据库迁移

蓝图blueprint


代码结构(有多余部分,以后列出个精简版):

主要构造是:

form(描述页面展示的框框), view(视图构造函数,map URL和HTML), templates(前端代码HTML),  model(数据库中的每个table数据结构),Config(配置文件)

前端页面布局展示可以放到static 文件夹中


具体如下:

|-- microblog
|   |-- app
|   |   |-- __init__.py
|   | 
|   |   |-- auth
|   |   |   |-- __init__.py
|   |   |  
|   |   |   |-- forms.py
|   |   |  
|   |   |   |-- views.py
|   |   | 
|   |   |-- db_create.py
|   |   |-- decorators.py
|   |   |-- email.py
|   |   
|   |   |-- main
|   |   |   |-- __init__.py
|   |   |  
|   |   |   |-- errors.py
|   |   |
|   |   |   |-- forms.py
|   |   |  
|   |   |   |-- views.py
|   |   |   
|   |   |  
|   |   |-- models.py
|   |  
|   |   |-- static
|   |   |   `-- styles.css
|   |   `-- templates
|   |       |-- 404.html
|   |       |-- _macros.html
|   |       |-- _posts.html
|   |       
|   |       |-- auth
|   |       |   |-- email
|   |       |   |   |-- confirm.html
|   |       |   |   |-- confirm.txt
|   |       |   |   |-- reset_password_email.html
|   |       |   |   `-- reset_password_email.txt
|   |       |   |-- forgetPwd.html
|   |       |   |-- login.html
|   |       |   |-- logout.html
|   |       |   |-- register.html
|   |       |   |-- resetPwd.html
|   |       |   `-- unconfirmed.html
|   |       |-- base.html
|   |       |-- edit.html
|   |       |-- index.html
|   |       |-- login.html
|   |      
|   |       |-- post.html
|   |       `-- user.html
|   |-- config.py
|   |-- config.pyc
|   |-- data.sqlite
|   |-- migrations
|   |   |-- README
|   |   |-- alembic.ini
|   |   |-- env.py
|   |   
|   |   |-- script.py.mako
|   |   `-- versions
|   |-- run.py
|   |-- test
|   |   `-- test_user_model.py


效果图如下,后续继续改进:




阅读全文
0 0