修复搜索框内查询

This commit is contained in:
lzjqsdd 2016-05-08 23:46:31 +08:00
parent 596bead678
commit 16faed70ce
3 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,8 @@ from ml.Search import Search
render = web.template.render('templates/')
urls=(
'/(.*)','index'
"/","index",
"/news","news"
)
app = web.application(urls,globals())
@ -14,17 +15,23 @@ app = web.application(urls,globals())
class index:
def __init__(self):
self.se = Search()
def GET(self,searchword):
def GET(self):
searchword = web.input().searchword
newslist=list()
if searchword:
newslist = self.se.QueryPhrase(searchword,False)
return render.header(searchword,newslist)
def POST(self):
searchword = web.input(searchword=[])
class news:
def __init__(self):
self.se = Search()
def GET(self):
searchword = web.input().searchword
newslist=list()
if searchword:
newslist = self.se.QueryPhrase(searchword,False)
return render.header(searchword,newslist)
if __name__ == "__main__":
app = web.application(urls,globals())
app.run()

Binary file not shown.

View File

@ -13,11 +13,9 @@ $def with(searchword,newslist)
<form class="bs-example bs-example-form" role="form">
<div class="col-lg-8">
<div class="input-group">
<input type="text" name="searchword" class="form-control" placeholder=$searchword>
<input type="text" class="form-control" name="searchword" placeholder=$searchword>
<span class="input-group-btn">
<button type="submit" class="btn btn-default" type="button">
搜索
</button>
<button class="btn btn-default" type="button">搜索</button>
</span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->