对于像我这样忘记了HTML的人,请确定
<input>
在你的
<form>
有一个
name=""
属性!
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
print("Posted data : {}".format(request.form))
return """
<form method="post">
<input type="text">
<input type="text" id="idtxt2">
<input type="text" name="txt3" id="idtxt3">
<input type="submit" Value="Hopla!">
</form>
"""
if __name__ == "__main__":
app.run()
控制台上的结果:
freezed@machine % python3 run.py
* Serving Flask app "flaskstuff.views" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 268-634-781
127.0.0.1 - - [20/Aug/2018 16:52:59] "POST / HTTP/1.1" 200 -
Posted data : ImmutableMultiDict([('txt3', 'text 3')])
不
名称属性
=
没有数据
在里面
ImmutableMultiDict([])
!