我做以下
- url: /user/.*
script: script.py
以及script.py中的以下处理:
class GetUser(webapp.RequestHandler):
def get(self):
logging.info('(GET) Webpage is opened in the browser')
self.response.out.write('here I should display user-id value')
application = webapp.WSGIApplication(
[('/', GetUser)],
debug=True)
看起来有些不对劲。
答案 0 :(得分:5)
在app.yaml
中,您想要执行以下操作:
- url: /user/\d+
script: script.py
然后在script.py
:
class GetUser(webapp.RequestHandler):
def get(self, user_id):
logging.info('(GET) Webpage is opened in the browser')
self.response.out.write(user_id)
# and maybe you would later do something like this:
#user_id = int(user_id)
#user = User.get_by_id(user_id)
url_map = [('/user/(\d+)', GetUser),]
application = webapp.WSGIApplication(url_map, debug=True) # False after testing
def main():
run_wsgi_app(application)
if __name__ == '__main__':
main()