【发布时间】:2013-04-26 03:19:12
【问题描述】:
我想在加载时解析 URL 以查看它是否有任何参数。我只是想建立一个基本测试,看看这是否可能。将http://example.com/?hiyall 之类的网址发送到 ParamHandler 的正确正则表达式是什么?
class ParamHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('parameters detected')
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('Hello World')
application = webapp2.WSGIApplication ([('/', MainHandler), ('/\?.*', ParamHandler)], debug=True)
【问题讨论】:
-
你的意思是所有以hiyall结尾的请求(例如phiyall)还是example.com/?hiyall=somevalue之类的get参数。
-
我的意思是任何涉及“example.com/?”的东西。我想我知道如何解析 url,但现在我需要知道如何在有参数时获取 url。
-
你能给我一些你想解析的网址的例子吗?你给example.com/?hiyall 的例子是无效的,除非?是一个正则表达式。在这种情况下example.com/shiyall 是有效的。
标签: python regex google-app-engine webapp2