0

I'm trying to set up a basic prototype with Google App Engine, and I'm getting the following error with the Google App Engine Launcher when trying to deploy:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 2: ordinal not in range(128)

I found this related SO thread, but I'm not quite sure how to correctly specify the decoding in my example. I'm using the following Python code:

import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
  def get (self, q):
    if q is None:
      q = 'index.html'

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

def main ():
  application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
  util.run_wsgi_app (application)

if __name__ == '__main__':
  main ()

Thanks for any assistance here.

Community
  • 1
  • 1
nickpish
  • 839
  • 4
  • 24
  • 43

1 Answers1

0

Make sure index.html is unicode ('utf-8' encoded) with your editor.

And I suggest you use webapp2, jinja and WSGI because webapp (django) template has been depricated. Now you use old style Python 2.5 coding for app engine.

Docs:

voscausa
  • 11,253
  • 2
  • 39
  • 67