我有这个函数:
def run():
if request.method == 'POST':
print(request.form['id_num'])
# fix later
else:
return render_template("apprun.html")
现在,它总是指向else语句,但是render_template函数不能正常工作。我得到的代码不是一个完全格式化的HTML页面,而是一个字符串。具体地说,我的网页显示的是html,而不是读取html并正确显示:
<!DOCTYPE html>
<html>
<head>
<title>Rips Lab</title>
</head>
<body>
<style type="text/css">
html {
background-color: #E4E0EE;
}
body {
font-family: "Helvetica","Arial";
font-size: 20px;
color: #000000;
}
</style>
<form>Enter participant ID number: <input type="number" name="id_num" pattern="^[0-9]*$" required></form>
<br><br>
<p name="data"></p>
</body>
</html>
文件夹层次结构是正确的;我将一个名为"templates“的文件夹存储在与我正在运行的python文件相同的位置。
你知道为什么它的格式不正确吗?
https://stackoverflow.com/questions/54974483
复制相似问题