3

I'm developing my first app with Flask and deploying to Heroku. Below is the error message I get locally and on Heroku. Also can be seen here: http://warm-beyond-4111.herokuapp.com/

jinja2.exceptions.TemplateNotFound TemplateNotFound: home.html

Longer version of the error here:

File "/app/.heroku/python/lib/python2.7/site-packages/flask/templating.py",
line 61, in get_source raise TemplateNotFound(template)
TemplateNotFound: home.html

Here's an overview of the app:

Directory: /helloflask

Procfile:

web: python run.py

requirements.txt

Flask==0.9
Jinja2==2.6
Werkzeug==0.8.3
distribute==0.6.28
wsgiref==0.1.2

run.py

import os
from helloflask import app
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=True)

Directory: /helloflask/helloflask

__init__.py

from flask import Flask, render_template
app = Flask(__name__)
import helloflask.views

views.py

from helloflask import app
from flask import Flask, render_template
@app.route('/')
def home():
return render_template('home.html')

Directory: /helloflask/templates

home.html = a standard HTML file

Directory: /helloflask/static/css

main.css = standard CSS file

I've scoured the Interwebs for an answer with no luck. Anyone seen this before?

dirn
  • 19,454
  • 5
  • 69
  • 74
cmuir
  • 35
  • 1
  • 4

2 Answers2

3

Try creating the templates folder at the root of the application /templates and see if that fixes the problem. I think you can set the templates folder in Flask, just can't find it now.

Also, you might like the github repo on flask deployment on Heroku. https://github.com/zachwill/flask_heroku

Also checkout this SO Post on folder structure - flask blueprint template folder You may want to use Flask Blueprints, if you prefer to keep templates under helloflask.

I don't use Flask on Heroku, so have not verified this setup. Hope this helps.

Community
  • 1
  • 1
sampathweb
  • 46
  • 2
1

The templates folder should be a part of the package as your app. Move it into /helloflask/helloflask.

See #2 from http://flask.pocoo.org/docs/quickstart/#a-minimal-application.

dirn
  • 19,454
  • 5
  • 69
  • 74