使用request.args.get传递URL参数时遇到了很多麻烦.
我的代码如下:
from flask import Flask, request
app= Flask(__name__)
@app.route('/post?id=post_id', methods=["GET"])
def show_post():
post_id=1232
return request.args.get('post_id')
if __name__=="__main__":
app.run(host='0.0.0.0')
Run Code Online (Sandbox Code Playgroud)
保存后,我总是在命令行中键入python filename.py,请参阅在http://0.0.0.0:5000/上运行(按CTRL + C退出)作为命令行上的返回,然后键入url (http:// ip_addres:5000/post?id = 1232)在chrome中查看它是否会返回1232,但它不会这样做!请帮忙.