-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaregamapa_server.py
57 lines (41 loc) · 1.18 KB
/
saregamapa_server.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""
Created on Mon Nov 27 15:21:38 2017
@author: Valerio Guarrasi
"""
import web
import json
import saregamapa_index as si
urls = (
'/', 'saregamapa_ui',
'/search', 'apply_search',
'/wordcloud', 'generate_wordcloud'
)
render = web.template.render('ui/')
class saregamapa_ui:
def GET(self):
return render.saregamapa_ui()
class apply_search:
def GET(self):
gData = web.input()
queryString = gData['qs']
output = {
'query': queryString,
'search_results': si.sIndex.apply_search(queryString, False)
}
web.header('Content-Type', 'application/json')
return json.dumps(output)
class generate_wordcloud:
def GET(self):
gData = web.input()
qs = gData['qs']
cc = int(gData['cc'])
output = {
'query': qs,
'cluster_count': cc,
'cluster_results': si.sIndex.cluster_data(qs, cc, False)
}
web.header('Content-Type', 'application/json')
return json.dumps(output)
app = web.application(urls, globals())
if __name__ == "__main__":
app.run()