jinja2exceptions TemplateNotFound:index.html 使用 uwsgi 但不使用 flask 运行
jinja2exceptions TemplateNotFound: index.html with uwsgi but not flask run
我在 RPi3 上使用 Alpine Linux 托管服务器。它有很多 uwsgi 插件,我已经安装了 uwsgi-[ corerouter, router_redirect, sslrouter, http, router_http ] 显然还有 uwsgi
当我执行
export FLASK_APP=myapp.py
flask run
并在另一个虚拟终端中
curl 127.0.0.1:5000
我的 index.html 页面已打印。
但是当我执行
uwsgi --wsgi-file myapp.py --callable app --master true --http-socket=0.0.0.0:2340
curl returns 上述jinja2异常templateNotFound
如何解决这个问题。我的目录结构是
-myapp.py
-templates
-index.html
使用下面的行设置绝对路径解决了这个错误。我想对于多个进程,它们可能会在不同的目录中工作。为应用程序设置绝对路径可以防止这种情况。
app = Flask(__name__, template_folder="templates_path", static_folder="static_path")
我在 RPi3 上使用 Alpine Linux 托管服务器。它有很多 uwsgi 插件,我已经安装了 uwsgi-[ corerouter, router_redirect, sslrouter, http, router_http ] 显然还有 uwsgi
当我执行
export FLASK_APP=myapp.py
flask run
并在另一个虚拟终端中
curl 127.0.0.1:5000
我的 index.html 页面已打印。 但是当我执行
uwsgi --wsgi-file myapp.py --callable app --master true --http-socket=0.0.0.0:2340
curl returns 上述jinja2异常templateNotFound
如何解决这个问题。我的目录结构是
-myapp.py
-templates
-index.html
使用下面的行设置绝对路径解决了这个错误。我想对于多个进程,它们可能会在不同的目录中工作。为应用程序设置绝对路径可以防止这种情况。
app = Flask(__name__, template_folder="templates_path", static_folder="static_path")