0

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) 
1

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

I made folder 'template' and placed index.html into it, then I made the following: import webapp2 JINJA_ENVIRONMENT = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname('template')), extensions=['jinja2.ext.autoescape']) class MainHandler(webapp2.RequestHandler): def get(self): template = JINJA_ENVIRONMENT.get_template('index.html'); self.response.write(template.render(template_values)); app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True) and it's still not working
Never add code in your comments, update your opening post with new code and complete error please

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.