python flask demo
vi hello.py
from flask import Flask,request,jsonify
app=Flask(__name__)
@app.route(\'/\')
def hello_flask():
return \"<h1>hello, Flask!</h1>\"
@app.route(\'/test\', methods=[\'POST\'])
def post_Data():
print(\'hh\')
postdata = request.form[\'id\']
recognize_info = {\'id\': postdata, \'info\': \'recv:\'}
return jsonify(recognize_info), 201
@app.route(\'/user/<u_id>\')
def user_info(u_id):
return {
\"msg\":\"success\",
\"data\":{
\"id\": u_id,
\"username\": \'yuz\',
\"age\": 18
}
}
if __name__==\'__main__\':
app.debug=True
app.run(host=\'0.0.0.0\',port=5000)
来源:https://blog.csdn.net/wowocpp/article/details/123257399
本站部分图文来源于网络,如有侵权请联系删除。