I'm learning Google App Engine right now with a book 'Using Google App Engine by Charles Severance'.
I am on chapter 6 and so far I have made app.yaml
, index.py
, index.html
in templates folder and the CSS file in the static folder.
My index.py
looks like this:
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()
Why am I am getting this error?
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