from flask import Flask, request from flask_cors import CORS app = Flask(__name__) CORS(app) @app.route('/') def index(): return '欢迎使用 Flask Demo 应用!' @app.route('/hello', methods=['GET', 'POST']) def hello(): if request.method == 'GET': name = request.args.get('name', '匿名用户') elif request.method == 'POST': name = request.json.get('name', '匿名用户') return f'你好,{name}!欢迎来到 Flask Demo 应用!' if __name__ == '__main__': app.run(debug=True, port=8080)
标签:__,name,flask,demo,app,request,Flask From: https://www.cnblogs.com/mxleader/p/17551915.html