forked from katryo/google_simple_search
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (21 loc) · 681 Bytes
/
app.py
File metadata and controls
31 lines (21 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from bottle import Bottle, route, run, static_file, request
from mako.template import Template
import googlesearch
import pdb
template = Template(filename='static/templates/index.tmpl')
app = Bottle()
@route('/static/:path#.+#', name='static')
def static(path):
return static_file(path, root='static')
@route('/results')
def results_get():
return template.render(items='')
@route('/results', method='POST')
def results():
query = request.forms.decode().get('query')
items = googlesearch.simple_search(query)
return template.render(items=items)
@route('/')
def greet():
return template.render(items='')
run(host='localhost', port=1234, debug=True)