Reputation: 31
I'm working on a project and i need to use multiple html pages to interact with my code like: viewing index.html first:-
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
and then when i press the sign out button the program should view this page:-
path = os.path.join(os.path.dirname(__file__), 'signOut.html')
self.response.out.write(template.render(path, template_values))
the problem is that the program views the two pages together at one time and this is not what i want.
could you plz tell me how can I view them seperately
Upvotes: 1
Views: 103
Reputation: 17624
You need something like this:
class MainPage(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))
class SignOutPage(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), 'signOut.html')
self.response.out.write(template.render(path, template_values))
application = webapp.WSGIApplication(
[('/', MainPage),
('/signout', SignOutPage)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Your two pages will then be available at http://yourapp.appspot.com/ and http://yourapp.appspot.com/signout
This assumes that your app.yaml is mapping both urls to your .py file.
Upvotes: 2