python - 烧瓶模板在 zeit 上呈现 500 错误
问题描述
您好我正在尝试使用 Python 和 Flask 创建我的网站,但它返回 500 错误。
from flask import Flask
from flask import render_template
app = Flask(__name__, template_folder='files')
@app.route('/projects')
def projects():
return render_template("index.html")
if __name__ == '__main__':
app.run(debug = True)
文件夹结构:
appdir
-myapp.py
+files
-index.html
Dockerfile:
FROM python:3-alpine
WORKDIR /usr/src
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
ENV GUNICORN_CMD_ARGS="--bind=0.0.0.0"
CMD ["gunicorn", "myapp:app"]
例外:
File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 86, in _get_source_fast
10/22 01:38 PM (2m)
raise TemplateNotFound(template)
10/22 01:38 PM (2m)
jinja2.exceptions.TemplateNotFound: index.html
解决方案
尝试使用其他端口号(例如 8080)运行
如果名称=='主':app.run(主机='0.0.0.0',端口=8080,调试=真)
推荐阅读
- jquery - 似乎我的班级同时获得了我的错误和成功课程,而它应该只获得成功课程
- sql-server - Azure - 应用服务 - 移动应用快速入门 - 连接数据库
- ios - iOS 12.2 - 缺少锁屏控件
- javascript - 无法在表单数据中附加文件
- regex - 在 perl 中排除特定目录
- python - 我可以调用不带括号的 Python 函数吗,比如 shell 命令。如果是这样,怎么做?
- arrays - 数组中值和索引之间的高效一对一映射
- codenameone - 根据虚拟键盘何时可见隐藏/显示选项卡
- bash - 从 Bash Unix shell 获取 Windows 用户名?
- android - 如何使用 Android 导航组件实现导航抽屉