我想用燒瓶從html窗體中獲取數據。表單顯示在網站上,但是當我提交python沒有收到它。使用燒瓶接收來自表格的數據
HTML代碼:
<form action="/signup" method="post">
<input type="text" name="email"></input>
<input type="submit" value="signup"></input>
</form>
Python代碼:
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/about/')
def about():
return render_template('about.html')
@app.route('/signup', methods = ['POST'])
def signup():
email = request.form['email']
print("The email address is '" + email + "'")
return redirect('/')
if __name__ == '__main__':
app.run(debug=True)
APP
--static
----的main.css
--templates
---- HTML代碼(home.html做爲)
Python代碼(hello.py)
什麼是例外? – stamaimer
哪裏給出了html代碼? – Fejs
將編輯顯示代碼位於 – Daniel