Alen
Alen

Reputation: 917

Google app engine Python issue

I developed app using html5 and php. Since php is not yet fully supported on google app engine I would like to change my php code to python because I have 8 lines of php code. Problem is, I'm total noob with python. I'm used to make index.html and that run fine with php, but when I try to run index.html with python then I get blank page. Can someone explain how to run html5 document with python on google app engine. This is what I tried:

html = """

 here goes my site

""";

import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.render(html);

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)

Upvotes: 0

Views: 500

Answers (1)

Crt Tax
Crt Tax

Reputation: 397

I checked the GAE python start tutorial. Maybe your code

self.render(html);

should be:

self.response.write("Hello world!");

I don't think the class webapp2.RequestHandler has the render function, because I've tried your code on GAE's cloud play ground, it raises an error:

AttributeError: 'MainHandler' object has no attribute 'render'

And if you want to render a template, it should be used like this:

......
template = JINJA_ENVIRONMENT.get_template('index.html')
self.response.write(template.render(template_values))

Documentation is here

Upvotes: 2

Related Questions