-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi_mk_request.py
97 lines (90 loc) · 3.93 KB
/
wsgi_mk_request.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import threading
from viewer import showIndex
from viewer import cardList
from viewer_cards import showCard
from viewer_cards import getInfo
from viewer_cards import runCode
from viewer_cards import getCode
from viewer_cards import clearCache
from redactor import claudiaRedactor
from redactor import runClaudia
from redactor import redactorTicket
from redactor import redactorProgress
from new_red import newRedactor
from new_red import newRunClaudia
from new_red import newRedactorTicket
from new_red import newRedactorProgress
#===============================================
class ClaudiaService:
sMain = None
@classmethod
def start(cls, config, in_container):
assert cls.sMain is None
cls.sMain = cls(config, in_container)
@classmethod
def request(cls, serv_h, rq_path, rq_args, mongo, httpd):
# thread = threading.currentThread().getName()
# if thread not in httpd.mLocks:
# lock = threading.Lock()
# lock.acquire()
# httpd.mLocks[thread] = lock
# lock.release()
# else:
# lock = httpd.mLocks[thread]
if rq_path == "/":
return serv_h.makeResponse(
content = showIndex(rq_args['data'], mongo, httpd).site)
elif (rq_path == "/card") and ("id" in rq_args['data']):
return serv_h.makeResponse(
content = showCard(rq_args['data'], mongo, httpd).site)
elif rq_path == "/redactor":
return serv_h.makeResponse(
content = claudiaRedactor(rq_args, mongo, httpd).site)
elif rq_path == "/redactor/run":
return serv_h.makeResponse(
content = runClaudia(rq_args['data'], mongo, httpd).site)
elif rq_path == "/list":
return serv_h.makeResponse(
content = cardList(rq_args['data'], mongo, httpd).site)
elif rq_path == "/card/info":
return serv_h.makeResponse(
content = getInfo(rq_args['data'], mongo, httpd).site)
elif rq_path == "/card/run":
return serv_h.makeResponse(
content = runCode(rq_args['data'], mongo, httpd).site)
elif rq_path == "/card/code":
return serv_h.makeResponse(
content = getCode(rq_args['data'], mongo, httpd).site)
elif rq_path == "/card/clear":
return serv_h.makeResponse(
content = clearCache(rq_args['data'], mongo, httpd).site)
elif rq_path == "/redactor/ticket":
return serv_h.makeResponse(
content = redactorTicket(rq_args['data'], mongo, httpd).site)
elif rq_path == "/redactor/progress":
return serv_h.makeResponse(
content = redactorProgress(rq_args['data'], mongo, httpd).site)
elif rq_path == "/new_red":
return serv_h.makeResponse(
content = newRedactor(rq_args, mongo, httpd).site)
elif rq_path == "/new_red/run":
return serv_h.makeResponse(
content = newRunClaudia(rq_args['data'], mongo, httpd).site)
elif rq_path == "/new_red/ticket":
return serv_h.makeResponse(
content = newRedactorTicket(rq_args['data'], mongo, httpd).site)
elif rq_path == "/new_red/progress":
return serv_h.makeResponse(
content = newRedactorProgress(rq_args['data'], mongo, httpd).site)
print('404. Page not found: ' + rq_path)
return serv_h.makeResponse(error = 404)
#===============================================
def __init__(self, config, in_container):
self.mConfig = config
self.mInContainer = in_container
# AnfisaData.setup(config)
self.mHtmlTitle = self.mConfig["html-title"]
self.mHtmlBase = (self.mConfig["html-base"]
if self.mInContainer else None)
if self.mHtmlBase and not self.mHtmlBase.endswith('/'):
self.mHtmlBase += '/'