1

My project structure is as below :

flask-blog/      
    application.py          
    templates/         
        home.html

My templates folder is also correctly named. I don't understand where the issue is!

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\app.py", line 1799, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)  

File "C:\project\application.py", line 6, in hello
  return render_template('hello.html')

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 134, in render_template
  return _render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 869, in get_or_select_template
  return self.get_template(template_name_or_list, parent, globals)

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 830, in get_template
  return self._load_template(name, self.make_globals(globals))

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\environment.py", line 804, in _load_template
  template = self.loader.load(self, name, globals)

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\jinja2\loaders.py", line 113, in load
  source, filename, uptodate = self.get_source(environment, name)

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 58, in get_source
  return self._get_source_fast(environment, template)

File "C:\Users\Aswathi\Anaconda3\lib\site-packages\flask\templating.py", line 86, in _get_source_fast
  raise TemplateNotFound(template)

jinja2.exceptions.TemplateNotFound: hello.html

absentia
  • 142
  • 2
  • 13

3 Answers3

1

always save html files in templates folder

VAMSHI P V
  • 11
  • 1
0

You are looking for the template hello.html, but the only template you have in your templates directory is home.html

SallyDa
  • 1
  • 1
0

Passing home in render_template instead of home.html worked for me

@app.route('/')
def hello():
    return render_template('home')
Varun Singh
  • 489
  • 3
  • 13