Flask 随记

python 2.x 中使用 virtualenv

virtualenv venv
(windows: venv\Scripts\activate)  (linux: source venv/bin/activate)
deactivate

 

python 3.x 使用内置

py -3 -m venv venv
venv\Scripts\activate.bat

deactivae

 

 

 

fake logic

 

app.run(host='0.0.0.0', port=5000, debug=True)

 

templates

create link between pages  (url_for)

 

form

css form

validate form

post-redirect-get pattern

flask-wtf wtf-form

 

session 

 

error handling

 

flask mail

app.config['MAIL_SERVER'] = 'smtp.163.com'
app.config['MAIL_PORT'] = '25'
app.config['MAIL_USERNAME'] = <username>
app.config['MAIL_PASSWORD'] = <password>
app.config['MAIL_USE_TLS'] = True
app.config['FLASKY_MAIL_SUBJECT_PREFIX'] = '[Flasky]'
app.config['FLASKY_MAIL_SENDER'] = 'Flasky Admin <yt8449960@163.com>'

 

 

debug 使用

 

  • Databases
  • Authentication
  • HTML/CSS 
  • Structure for large applications
  • API (REST API)
  • Rich client applications (Angular, Ember, React, etc.)
  • Unit Testing
  • Logging
  • Beyond HTTP: WebSocket
  • Deployment

 

posted @ 2016-02-06 21:16  whu.yt  阅读(210)  评论(0编辑  收藏  举报