Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
from flask import Flask
app = Flask(__name__)
@app.route('/hello',methods=['GET','POST'])
def hello_world():
return 'Hello World’
if __name__ == '__main__':
app.run()
(1)app.run(host,port,debug,options)
(2)Url 路径
@app.route('/hello/<name>')
def hello_name(name):
return 'Hello %s!' % name
带转换器
@app.route('/hello/<int:id>')
(3)获取GET参数
request.args.get('')
(4)获取POST数据
request.get_data()
request.get_json()