pip install flash
from flash import Flash app = Flash(__name__)
@app.route(‘/‘) def index(): return (‘<h1>Hello World</h1>‘)
@app.route(‘/user/<name>‘) def user(name): return (‘<h1>Hello World,%s</h1>‘)%name
if __name__== ‘__main__‘: app.run(debug=True)
变量名 | 上下文 | 说明 |
current_app | 程序上下文 | 当前激活程序的程序实例 |
g | 程序上下文 | 处理请求用作临时存储的对象,每次请求都会重设这个变量 |
request | 请求上下文 | 请求对象,封装了客户端发出的HTTP请求的内容 |
session | 请求上下文 | 用户会话,用于存储请求之间需要“记住”的值得词典 |
before_first_request:注册一个函数,可在处理第一个请求之前运行
before_request:注册一个函数,在每次请求之前运行
after_request:注册一个函数,如果没有未处理的异常抛出,每次请求之后运行
teardown_request:注册一个函数,及时有未处理的异常抛出,也在每次请求之后运行
安装:pip install flash-script
from flask.ext.script import Manager manager = Manager(app) if __name__ == ‘__main__‘: manager.run()
hello.py runserver [-h] [-t HOST] [-p PORT] [--threaded] [--processe PROCESSES] [--passthrough-errors] [-d] [-r]
原文:https://www.cnblogs.com/cxys85/p/10431852.html