我做了以下事情
- 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)
看起来那里有问题。
最佳答案
在 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()
关于python - 如何配置 app.yaml 以支持像/user/<user-id> 这样的 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5763425/