当用户访问在我的烧瓶应用程序上运行的此 URL 时,我希望 Web 服务能够处理问号后指定的参数:
http://10.1.1.1:5000/login?username=alex&password=pw1 #I just want to be able to manipulate the parameters @app.route('/login', methods=['GET', 'POST']) def login(): username = request.form['username'] print(username) password = request.form['password'] print(password)
用于request.args获取查询字符串的解析内容:
request.args
from flask import request @app.route(...) def login(): username = request.args.get('username') password = request.args.get('password')