【发布时间】:2013-08-27 10:25:25
【问题描述】:
我想按查询搜索,如下所示。
http://localhost:8080/search?query=a
html
...
<form class="navbar-form navbar-right" name="searchform" action="/search" method="post">
<div class="form-group">
<input class="form-control" placeholder="Any keyword" type="text" name="query" />
</div>
<button class="btn btn-success" type="submit">Search</button>
</form>
...
routes.py
...
import handlers
_routes = [
RedirectRoute('/search?query=<.*>', handlers.SearchHandler, name='search', handler_method='post')
]
...
handlers.py
...
class SearchHandler(BaseHandler):
def get(self):
params = {
'query': '',
'offset': '0'
}
self.doSearch(params)
def doSearch(self, params):
docs = search.Index(name='indexed_doc')
query = params.get('query', '')
try:
offset_value = int(params.get('offset' or 0))
except ValueError:
offset_value = 0
try:
search_query = search.Query(...
result against: '/search?query=<.>' at routes.py
error_handler.py:71] 错误 403:对此资源的访问被拒绝。
module.py:593] 默认值:“POST /search HTTP/1.1”403 2555
结果反对:'/search(.*)' at routes.py
error_handler.py:71] 错误 404:找不到资源。
module.py:593] 默认值:“POST /search HTTP/1.1”404 2543
如何为它编写正则表达式?或者有什么问题?
提前致谢。
【问题讨论】:
标签: python regex google-app-engine webapp2