I'm having same issue as described in these two questions/answers:
Python WSGI + Flask render_template - 500 Internal Server Error?
Getting a 500 Internal Server Error using render_template and Flask
and I've narrowed it to the following:
Here's the file structure:
../project/
project.py
templates/
about.html
I'm still getting this error (shorten):
● project.service - Gunicorn instance to serve project
Loaded: loaded (/etc/systemd/system/project.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-02-15 06:28:46 UTC; 3min 28s ago
Main PID: 3942 (gunicorn)
Tasks: 4 (limit: 1151)
CGroup: /system.slice/project.service
├─3942 /home/dev/project/project_env/bin/python3.6 /home/dev/project/project_env/bin/gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi
├─3967 /home/dev/project/project_env/bin/python3.6 /home/dev/project/project_env/bin/gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi
├─3968 /home/dev/project/project_env/bin/python3.6 /home/dev/project/project_env/bin/gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi
└─3969 /home/dev/project/project_env/bin/python3.6 /home/dev/project/project_env/bin/gunicorn --workers 3 --bind unix:project.sock -m 007 wsgi
Feb 15 06:29:17 project gunicorn[3942]: return self._load_template(name, self.make_globals(globals))
Feb 15 06:29:17 project gunicorn[3942]: File "/home/dev/project/project_env/lib/python3.6/site-packages/jinja2/environment.py", line 857, in _load_template
Feb 15 06:29:17 project gunicorn[3942]: template = self.loader.load(self, name, globals)
Feb 15 06:29:17 project gunicorn[3942]: File "/home/dev/project/project_env/lib/python3.6/site-packages/jinja2/loaders.py", line 117, in load
Feb 15 06:29:17 project gunicorn[3942]: source, filename, uptodate = self.get_source(environment, name)
Feb 15 06:29:17 project gunicorn[3942]: File "/home/dev/project/project_env/lib/python3.6/site-packages/flask/templating.py", line 60, in get_source
Feb 15 06:29:17 project gunicorn[3942]: return self._get_source_fast(environment, template)
Feb 15 06:29:17 project gunicorn[3942]: File "/home/dev/project/project_env/lib/python3.6/site-packages/flask/templating.py", line 89, in _get_source_fast
Feb 15 06:29:17 project gunicorn[3942]: raise TemplateNotFound(template)
Feb 15 06:29:17 project gunicorn[3942]: jinja2.exceptions.TemplateNotFound: about.html
So the issue as far as I can tell, is that last line
Feb 15 06:29:17 project gunicorn[3942]: jinja2.exceptions.TemplateNotFound: about.html
I don't understand why, even though the files/folders are there. The closest I could find is this comment:
https://stackoverflow.com/a/56589998/12070612
ENV = jinja2.Environment(loader=jinja2.FileSystemLoader(str(root_path / 'templates')))
template = ENV.get_template(your_template_name)
But if I add the "ENV=..." lines to my project.py file, then Gunicorn complaints and fails to start process.