title: Flask doesn't locate template directory when running with twisted
body: <p>Following some advice that I found <a href="https://stackoverflow.com/questions/5248825/web-interface-for-a-twisted-application">here</a> I am trying to use Flask as a web interface for an application that runs with twisted.</p>
  
  <p>As suggested in Flask documentation I created a "templates" directory which is at the same level as my script but when I launch the server I get the following error:</p>
  
  <blockquote>
    <p>Internal Server Error</p>
    
    <blockquote>
      <p>The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.</p>
    </blockquote>
  </blockquote>
  
  <p>When I do not try to load a template and just write a string in the request it works fine. This is what makes me think it is related to the load of the template.</p>
  
  <pre><code>from twisted.internet import reactor
  from twisted.web.resource import Resource
  from twisted.web.wsgi import WSGIResource
  from twisted.internet.threads import deferToThread
  from twisted.web.server import Site, NOT_DONE_YET
  
  from flask import Flask, request, session, redirect, url_for, abort, \ 
  render_template, flash
  
  app= Flask(__name__)
  app.config.from_object(__name__)
  
  @app.route('/login', methods= ['GET', 'POST'])
  def login():
      return render_template('login.html', error= error)
  
  if __name__ == '__main__':
      root = WSGIResource(reactor, reactor.getThreadPool(), app)
      factory = Site(root)
      reactor.listenTCP(8880, factory)
      reactor.run()
  </code></pre>