I am building an application using webapp2 in Google App Engine. How do I pass the username into the url so that when the profile button is clicked, it takes the user to “/profile/username” where “username” is specific to the user?
My current handlers:
app = webapp2.WSGIApplication([('/', MainPage),
('/signup', Register),
('/login', Login),
('/logout', Logout),
('/profile', Profile)
],
debug=True)
the Profile class:
class Profile(BlogHandler):
def get(self):
email = self.request.get('email')
product = self.request.get('product')
product_list = db.GqlQuery("SELECT * FROM Post ORDER BY created DESC LIMIT 10")
self.render('profile.html', email = email, product = product, product_list = product_list)
I am trying to send each user to a Profile page that contains information in my database specific to them. Thanks
One possible solution would be to simply have one URL, i.e.,
/profile. The corresponding handler would render the response with data coming from the logged-in user.If you really want to have URLs like
/profile/username, you could define a route:and access the username in your handler:
But depending on your application, you might want to make sure only the logged-in user has access to its
/profile/usernameby adding a check somewhere in the handler.