-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
24 lines (17 loc) · 711 Bytes
/
server.py
File metadata and controls
24 lines (17 loc) · 711 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
from flask import Flask, render_template, request
from search import search
app = Flask(__name__)
@app.route('/', methods=['POST','GET'])
def search_box():
if request.method == 'POST':
query = request.form['searchTerm']
type_of_query = request.form['typequeery']
res = search(query,type_of_query)
hits = res['hits']['hits']
aggs = res['aggregations']
num_results = len(hits)
return render_template('index.html',query=query,hits=hits,num_results=num_results,aggs=aggs)
if request.method == 'GET':
return render_template('index.html',init='True')
if __name__ == "__main__":
app.run(host='0.0.0.0',port=3000,debug=True)