Flask模板在Zeit上渲染500错误

时间:2018-10-22 10:22:05

标签: python flask

嗨,我正在尝试使用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

1 个答案:

答案 0 :(得分:0)

尝试使用其他端口号(例如8080)运行

如果名称 =='主要”:    app.run(host ='0.0.0.0',port = 8080,debug = True)