嗨,我试图创建我的网站使用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)运行
如果名称=='main': 应用程序运行(host='0.0.0.0',port=8080,debug=True)
相关问题 更多 >
编程相关推荐