-
Notifications
You must be signed in to change notification settings - Fork 12
/
concordance.py
executable file
·37 lines (29 loc) · 1 KB
/
concordance.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
#!/usr/bin/env python3
import os
from wsgiref.handlers import CGIHandler
import json
import sys
sys.path.append("..")
import custom_functions
try:
from custom_functions import concordance_results
except ImportError:
from philologic.runtime import concordance_results
try:
from custom_functions import WebConfig
except ImportError:
from philologic.runtime import WebConfig
try:
from custom_functions import WSGIHandler
except ImportError:
from philologic.runtime import WSGIHandler
def concordance(environ, start_response):
config = WebConfig(os.path.abspath(os.path.dirname(__file__)).replace('reports', ''))
request = WSGIHandler(environ, config)
concordance_object = concordance_results(request, config)
headers = [('Content-type', 'application/json; charset=UTF-8'),
("Access-Control-Allow-Origin", "*")]
start_response('200 OK', headers)
yield json.dumps(concordance_object).encode('utf8')
if __name__ == "__main__":
CGIHandler().run(concordance)