-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
67 lines (55 loc) · 1.76 KB
/
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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/6/6 下午4:25
# @Author : Stardustsky
# @File : m_reg.py
# @Software: PyCharm
import os
import tornado.ioloop
import tornado.web
import tornado.websocket
import tornado.httpserver
import urllib
from center import check_for_api
class IndexHandler(tornado.web.RequestHandler):
def get(self):
pack = self.get_query_argument("payload")
# pack = self.request.body
json_pack = urllib.unquote(pack)
# print json_pack
try:
res = check_for_api(json_pack)
self.write(res)
except Exception as e:
self.write(e)
def post(self):
# pack = self.get_query_argument("payload")
pack = self.request.body
json_pack = urllib.unquote(pack)
try:
res = check_for_api(json_pack)
self.write(res)
except Exception as e:
self.write(e)
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r'/svm_waf/', IndexHandler),
]
settings = {
"static_path": os.path.join(os.path.dirname(__file__), "static"),
"template_path": os.path.join(os.path.dirname(__file__), "templates"),
"cookie_secret": "bZJc2sWbQLKos6GkHn/VB9oXwQt8S0R0kRvJ5/xJ89E=",
"xsrf_cookies": False,
"login_url": "/svm_waf/"
}
tornado.web.Application.__init__(self, handlers, **settings)
if __name__ == '__main__':
port = 9999
app = Application()
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(port)
tornado.ioloop.IOLoop.current().start()
# http_server.bind(port)
# http_server.start(0)
# tornado.ioloop.IOLoop.instance().start()