我想按查询搜索,如下所示。
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>
...
路线.py
...
import handlers
_routes = [
RedirectRoute('/search?query=<.*>', handlers.SearchHandler, name='search', handler_method='post')
]
...
处理程序.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(...
结果针对:'/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
我怎样才能为它编码正则表达式?或者有什么问题?
提前致谢。