Reputation: 3
I am trying to deploy my app on Heroku but it is giving Internal Server Error with Exception on / [GET] and raise TemplateNotFound,but it is successfully running on local host.After running heroku logs --tails,i am getting the following issues :
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
I have my Code in Credit.py file
following is my Procfile :
web: gunicorn Credit:app
following is my requirement.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
Directory Structure :
| .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
Didn't add the env directory structure because it was too big
My credit.py file is too big to share,so it can be viewed at : https://github.com/Shrikant991/Credit-Management-System-in-Flask/blob/master/Credit.py
Any suggestions?
Upvotes: 0
Views: 524
Reputation: 1
the letter 't' for 'templates' need to be capitalised. 'DIRS': [os.path.join(BASE_DIR, 'Templates')],
Upvotes: 0
Reputation: 1141
As per your git repo and the directory structure most likely its due to case sensitivity for folder templates
t should be small.
Try editing your code to this.
app = Flask(__name__, template_folder='Templates')
Or rename your Templates
folder to templates
Upvotes: 1