-
Notifications
You must be signed in to change notification settings - Fork 1
/
PSETWebServer.py
50 lines (32 loc) · 1.02 KB
/
PSETWebServer.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
# coding=utf8
"""
- author = wangjiawei
- date = 2018-10-08
- quote: pste 的web服务
"""
import tornado.web
from tornado.ioloop import IOLoop
from utils import json_dumps
from pste_spider import executoer_for_web_server
from utils import logger
class MainHandler(tornado.web.RequestHandler):
param_names = ['pname', 'cardNum']
def get(self):
self.write('welcome')
def post(self):
api_info = self.lets_do_spider()
self.write(api_info)
del api_info
def lets_do_spider(self):
"""针对2.0版本"""
# 省略了参数验证环节
pname = self.get_argument('pname')
cardNum = self.get_argument('cardNum')
# 使用多进程
logger.debug('接受参数:\t{0}\t{1}'.format(pname, cardNum))
result = executoer_for_web_server(pname, cardNum)
return json_dumps(result)
application = tornado.web.Application([(r"/pste", MainHandler),])
if __name__ == "__main__":
application.listen(22000)
IOLoop.instance().start()