我已经查看了有关此错误的所有其他问题,但要么解决方案不起作用,要么我已经按照解决方案所说的去做了。我的 app.py 代码:
@app.route("/", methods=["POST", "GET"])
def index():
if request.method == "POST":
article_content = request.form["article_content"]
threshold_val = request.form["threshold_input"]
predictionCount = request.form["prediction_count"]
HTML 代码:
<div>
<div>
<form action="/" method="POST">
<input class="Input-Box" type="text" name="article_content" />
<br />
<br />
<input type="submit" value="Find Systems" />
</form>
</div>
<div class="Settings">
<div style="align-items: center; display: inline-block;">
<h6>Threshold Value(0-1.0):</h6>
<form action="/" method="POST">
<input type="text" name="threshold_input" />
</form>
</div>
<div style="align-items: center; display: inline-block;">
<h6>Number of predictions(1-24):</h6>
<form action="/" method="POST">
<input type="text" name="prediction_count" />
</form>
</div>
</div>
</div>
</div>
有趣的是,Flask 从“article_content”获取输入没有问题,但会匹配“threshold_input”和“prediction_count”。我检查了 POST 方法,将 HTML 表单设置为 POST 方法,并确保 HTML 元素的名称和 request.form 函数中的文本相同。任何帮助,将不胜感激。追溯如下:
Traceback (most recent call last)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
浮云间
相关分类