当用户访问在我的flask应用程序上运行的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')