2016-05-08 00:27:26 +08:00
|
|
|
import web
|
|
|
|
import sys
|
|
|
|
sys.path.append("..")
|
|
|
|
from ml.Search import Search
|
|
|
|
|
|
|
|
render = web.template.render('templates/')
|
|
|
|
|
|
|
|
urls=(
|
2016-05-08 23:46:31 +08:00
|
|
|
"/","index",
|
|
|
|
"/news","news"
|
2016-05-08 00:27:26 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
app = web.application(urls,globals())
|
|
|
|
|
|
|
|
class index:
|
|
|
|
def __init__(self):
|
|
|
|
self.se = Search()
|
2016-05-08 23:46:31 +08:00
|
|
|
def GET(self):
|
2016-05-09 21:26:35 +08:00
|
|
|
data = web.input()
|
|
|
|
if data:
|
|
|
|
searchword = data.searchword
|
|
|
|
else:
|
|
|
|
searchword = ''
|
2016-05-08 00:27:26 +08:00
|
|
|
newslist=list()
|
|
|
|
if searchword:
|
2016-05-09 21:26:35 +08:00
|
|
|
newslist = self.se.QueryByTime(searchword)
|
|
|
|
return render.index(searchword,newslist)
|
2016-05-08 23:46:31 +08:00
|
|
|
|
|
|
|
class news:
|
|
|
|
def __init__(self):
|
|
|
|
self.se = Search()
|
|
|
|
def GET(self):
|
2016-05-09 21:26:35 +08:00
|
|
|
data = web.input()
|
|
|
|
if data:
|
|
|
|
ID = data.id
|
|
|
|
else:
|
|
|
|
ID=''
|
|
|
|
news = self.se.QueryById(ID)
|
|
|
|
return render.news(news)
|
2016-05-08 23:46:31 +08:00
|
|
|
|
2016-05-08 00:27:26 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
app = web.application(urls,globals())
|
|
|
|
app.run()
|