In the following example, the .html data is in the same file as the Python code (as variable MAIN_PAGE_HTML).
I want the .html content in its own different file.
How do I present the HTML page? Must I always use Jinja2 to load it?
Or is there a simpler way to get the content of my .html and pass it to self.response.write?
import cgi from google.appengine.api import users import webapp2
MAIN_PAGE_HTML = """\ <html> <body>
<form action="/sign" method="post">
<div><textarea name="content" rows="3" cols="60"></textarea></div>
<div><input type="submit" value="Sign Guestbook"></div>
</form> </body> </html> """
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(MAIN_PAGE_HTML)
class Guestbook(webapp2.RequestHandler):
def post(self):
self.response.write('<html><body>You wrote:<pre>')
self.response.write(cgi.escape(self.request.get('content')))
self.response.write('</pre></body></html>')
application = webapp2.WSGIApplication([
('/', MainPage),
('/sign', Guestbook), ], debug=True)
My .html file contains a form that user can fill and send to me.