Flask-實現博客基本功能

功能:

新用戶註冊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


效果圖如下,後續繼續改進:




發佈了47 篇原創文章 · 獲贊 32 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章