Flask Quick Start

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.
This link: https://blog.csdn.net/weixin_42818402/article/details/100577399
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()

Guess you like

Origin blog.csdn.net/weixin_42818402/article/details/100577399