【发布时间】:2012-10-07 17:13:06
【问题描述】:
我想访问给定请求的 URI 参数:
http://localhost:8080/account/user?un=erik&pw=gaius
我不能让下面的代码工作,
main.py
app = webapp2.WSGIApplication([('/', MainPage),
('/account/user', account.User)],
debug=True)
account.py
class User(webapp2.RequestHandler):
def get(self, un, pw):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Yey!' + un + ' ' + pw)
我认为我的 main.py 有问题,但我试图通过添加命名路由和正则表达式来解决它,但我一直收到 500 个错误(内部服务器错误)。
【问题讨论】:
-
我怀疑使用 '/account/user/
/ 的正则表达式仅适用于 URL 部分,而不适用于查询部分(您不希望它成为路由的一部分)
标签: python google-app-engine webapp2