title: Python, Google App Engine error: assert type(data) is StringType,"write() argument must be string"
body: <p>I'm learning Google App Engine right now with a book 'Using Google App Engine by Charles Severance'.</p>
  
  <p>I am on chapter 6 and so far I have made <code>app.yaml</code>, <code>index.py</code>, <code>index.html</code> in templates folder and the CSS file in the static folder.</p>
  
  <p>My <code>index.py</code> looks like this:</p>
  
  <pre><code>import os
  import wsgiref.appengine.ext import webapp
  from google.appengine.ext import webapp
  from google.appengine.ext.webapp import template
  
  class MainHandler(webapp.RequestHandler):
        def get(self):
            path=self.request.path
            temp=os.path.join(os.path.dirname(__file__, 'templates' + path)
            if not os.path.isfile(temp):
               temp=os.path.join(os.path.dirname(__file__, 'templates/index.html')
  
            self.response.out.write(template.render(temp,{}))
  
  def main():
      application = webapp.WSGIApplication([('/.*', MainHandler)], debug=True)
      wsgiref.handlers.CGIHandler().run(application)
  
  if __name == '__main__':
     main()
  </code></pre>
  
  <p>Why am I am getting this error?</p>
  
  <pre><code>Traceback (most recent call last):
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 86, in run
      self.finish_response()
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 127, in finish_response
      self.write(data)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 202, in write
      **assert type(data) is StringType,"write() argument must be string"**
  
  AssertionError: write() argument must be string
  </code></pre>