用于提取 URI 参数的正则表达式,例如 webapp2 (Python) 中的 URL's?
Regex to extract URI arguments such as URL's in webapp2 (Python)?
在 routes.py 中,我尝试了以下代码(不是正则表达式专家)并打算在 url_arg 中传递 http/https 链接,例如http://google.com or https://google.com.
r'/some_api/<url_arg:.*>'
这是 localhost:8080/some_api/https://google.com or localhost:8080/some_api/http://google.com
的错误
Traceback (most recent call last):
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1292, in communicate
req.parse_request()
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 580, in parse_request
success = self.read_request_line()
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 643, in read_request_line
scheme, authority, path = self.parse_request_uri(uri)
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 805, in parse_request_uri
authority, path = remainder.split(FORWARD_SLASH, 1)
ValueError: need more than 1 value to unpack
这似乎是应用引擎的 devappserver2 使用的 cherrypy 中的错误。详情:https://code.google.com/archive/p/appengine-devappserver2-experiment/issues/69
(我遇到了同样的问题,目前还没有很好的修复或解决方法。)
在 routes.py 中,我尝试了以下代码(不是正则表达式专家)并打算在 url_arg 中传递 http/https 链接,例如http://google.com or https://google.com.
r'/some_api/<url_arg:.*>'
这是 localhost:8080/some_api/https://google.com or localhost:8080/some_api/http://google.com
的错误Traceback (most recent call last):
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1292, in communicate
req.parse_request()
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 580, in parse_request
success = self.read_request_line()
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 643, in read_request_line
scheme, authority, path = self.parse_request_uri(uri)
File "/google-cloud-sdk/platform/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 805, in parse_request_uri
authority, path = remainder.split(FORWARD_SLASH, 1)
ValueError: need more than 1 value to unpack
这似乎是应用引擎的 devappserver2 使用的 cherrypy 中的错误。详情:https://code.google.com/archive/p/appengine-devappserver2-experiment/issues/69
(我遇到了同样的问题,目前还没有很好的修复或解决方法。)