Flask doesn't locate template directory when running with twisted Flask doesn't locate template directory when running with twisted flask flask

Flask doesn't locate template directory when running with twisted


Some frameworks will change directory from your current working directory when they are run in daemon mode, and this might very well be the case here.

Flask, since 0.7, has supported passing a template_folder keyword argument when calling Flask, so you could try:

import ostmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')

The following is a shorter version that will work just fine:

tmpl_dir = os.path.join(os.path.dirname(__file__), 'templates)# ...app = Flask('myapp', template_folder=tmpl_dir)


You can feed Jinja2 with a default templates directory (as written here) like this :

import jinja2app = Flask(__name__)app.jinja_loader = jinja2.FileSystemLoader('path/to/templates/directory')