【发布时间】:2020-06-24 13:36:00
【问题描述】:
这是我的 Python 代码:
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/profile/<name>")
def profile(name):
return render_template("index.html", name=name)
if __name__ == "__main__":
app.run()
和 HTML 代码:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Hello {{ name }}
</body>
</html>
当我运行 Python 代码时,它会在浏览器上显示:
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
我在 Google 和 Youtube 上寻找解决方案,但仍然无法解决。有人可以帮我弄这个吗?谢谢
编辑:所以我需要做的就是修复这一行:
app = Flask(__name__, template_folder="template")
【问题讨论】:
-
能否请您切换到调试模式 app.run(debug=True) 以便向我们提供更多详细信息?
-
@Charles R 现在说“jinja2.exceptions.TemplateNotFound jinja2.exceptions.TemplateNotFound: index.html”
-
所以你的寺庙可能不在正确的目录中。默认情况下 template_forders="templates" 带有复数 S,您指定的模板不带 S
标签: python web flask internal-server-error