from flask import render_template
from flask import Flask
from flask import request
from flask import jsonify
app = Flask(__name__)
@app.route('/')
def home():
return render_template("index.html")
@app.route('/graph', methods=['POST'])
def graph():
fchoice = request.form['user']
schoice = request.form['password']
return choice + " " + choice
这是index.html
中的html:
<form action="/graph" method="post">
<input type="text" placeholder="first choice" name="user" disabled id="chose">
<input type="text" placeholder="second choice" name="password" disabled id="chose1">
<input type="submit" value="Vote">
</form>
答案 0 :(得分:1)
您正在尝试连接未定义的变量。
return choice + " " + choice
你没有choice
。您有fchoice
和schoice
。
@app.route('/graph', methods=['POST'])
def graph():
fchoice = request.form['user']
schoice = request.form['password']
return fchoice + " " + schoice