NewsSpider/web/main.py
2016-05-08 23:46:31 +08:00

38 lines
756 B
Python
Executable File

import web
import sys
sys.path.append("..")
from ml.Search import Search
render = web.template.render('templates/')
urls=(
"/","index",
"/news","news"
)
app = web.application(urls,globals())
class index:
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)
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()