python-在heroku上部署flask应用程序,但在/[get]上给出异常,未找到模板

2021-01-08 20点热度 0人点赞 0条评论

我正在尝试在Heroku上部署我的应用程序,但它在/[get]上出现内部服务器错误,并引发templateNotFound,但它已在本地主机上成功运行。运行Heroku日志--tails后,我遇到以下问题:

2019-07-09T10:28:00.953042+00:00 app[web.1]: [2019-07-09 10:28:00,950] ERROR in app: Exception on / [GET]
2019-07-09T10:28:00.953061+00:00 app[web.1]: Traceback (most recent call last):
2019-07-09T10:28:00.953064+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
2019-07-09T10:28:00.953066+00:00 app[web.1]: response = self.full_dispatch_request()
2019-07-09T10:28:00.953069+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
2019-07-09T10:28:00.953071+00:00 app[web.1]: rv = self.handle_user_exception(e)
2019-07-09T10:28:00.953074+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
2019-07-09T10:28:00.953076+00:00 app[web.1]: reraise(exc_type, exc_value, tb)
2019-07-09T10:28:00.953078+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
2019-07-09T10:28:00.953081+00:00 app[web.1]: raise value
2019-07-09T10:28:00.953083+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
2019-07-09T10:28:00.953085+00:00 app[web.1]: rv = self.dispatch_request()
2019-07-09T10:28:00.953087+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
2019-07-09T10:28:00.953089+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args)
2019-07-09T10:28:00.953091+00:00 app[web.1]: File "/app/Credit.py", line 52, in home
2019-07-09T10:28:00.953094+00:00 app[web.1]: return render_template('home.html')
2019-07-09T10:28:00.953095+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/templating.py", line 138, in render_template
2019-07-09T10:28:00.953098+00:00 app[web.1]: ctx.app.jinja_env.get_or_select_template(template_name_or_list),
2019-07-09T10:28:00.953104+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/jinja2/environment.py", line 869, in get_or_select_template
2019-07-09T10:28:00.953106+00:00 app[web.1]: return self.get_template(template_name_or_list, parent, globals)
2019-07-09T10:28:00.953107+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/jinja2/environment.py", line 830, in get_template
2019-07-09T10:28:00.953109+00:00 app[web.1]: return self._load_template(name, self.make_globals(globals))
2019-07-09T10:28:00.953110+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/jinja2/environment.py", line 804, in _load_template
2019-07-09T10:28:00.953112+00:00 app[web.1]: template = self.loader.load(self, name, globals)
2019-07-09T10:28:00.953113+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/jinja2/loaders.py", line 113, in load
2019-07-09T10:28:00.953115+00:00 app[web.1]: source, filename, uptodate = self.get_source(environment, name)
2019-07-09T10:28:00.953117+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/templating.py", line 60, in get_source
2019-07-09T10:28:00.953118+00:00 app[web.1]: return self._get_source_fast(environment, template)
2019-07-09T10:28:00.953120+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/flask/templating.py", line 89, in _get_source_fast
2019-07-09T10:28:00.953121+00:00 app[web.1]: raise TemplateNotFound(template)
2019-07-09T10:28:00.953127+00:00 app[web.1]: jinja2.exceptions.TemplateNotFound: home.html

我的代码在credit.py文件中

以下是我的程序文件:

web: gunicorn Credit:app

以下是我的要求.txt:

Click==7.0
Flask==1.1.1
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.2
gunicorn==19.9.0
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
SQLAlchemy==1.3.5
Werkzeug==0.15.4
WTForms==2.2.1

目录结构:

|   .gitignore
|   Credit.py
|   Procfile
|   requirements.txt
|   site.db
|   tree.txt
|   
+---env
+---templates
|   |   about.html
|   |   accounts.html
|   |   home.html
|   |   layout.html
|   |   transactions.html
|   |   users.html
|   |   
|   \---includes
|           _navbar
|           _navbar.html
|           
\---__pycache__
        Credit.cpython-37.pyc

没有添加env目录结构,因为它太大

我的credit.py文件太大,无法共享,因此可以在以下位置查看:abraham

有什么建议吗?

查看隐藏内容需要支付:¥1
查看

未经允许不得转载!python-在heroku上部署flask应用程序,但在/[get]上给出异常,未找到模板

本文地址:https://ans.52learn.online/2132

ANS52LEARN

DO BEST