-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathserver.py
95 lines (79 loc) · 3.03 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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/12/7 下午2:17
# @Author : Stardustsky
# @File : test_server.py
# @Software: PyCharm
import os
import tornado.ioloop
import tornado.web
import tornado.websocket
import tornado.httpserver
import urllib
import HTMLParser
import json
from module.core import news_status,market_status,plate_status,stock_status,core_func
from module.stock_notice import *
from module.func import *
class IndexHandler(tornado.web.RequestHandler):
def get(self):
market_score, market_info, money_flow, gb_data, hot_info = core_func()
driver = driver_init()
try:
stock = str(self.get_argument("stock"))
select_type = str(self.get_argument("select_type"))
sub = self.get_argument("sub")
if sub:
stock_info = stock_status(stock, driver, stock_type=select_type)
driver.quit()
self.render("index.html",
market=[market_score, market_info],
research=gb_data,
money=money_flow,
market_hot=hot_info,
stock_self=stock_info,
stock_code=stock
)
except:
print u'Failed to get stock info.'
stock_info = dict()
stock_info['basic_score'] = "None"
stock_info['basic_info'] = "None"
stock_info['stock_analysis'] = "None"
stock_info['active_score'] = "None"
stock_info['active_info'] = "None"
stock_info['stock_businiess'] = "None"
stock_info['stock_concept'] = "None"
stock_info['stock_news'] = "None"
stock_info['affair'] = "None"
stock_info['nine_change_index'] = "0"
stock_info['nine_change_info'] = "None"
self.render("index.html",
market=[market_score, market_info],
research=gb_data,
money=money_flow,
market_hot=hot_info,
stock_self=stock_info,
stock_code=u"None"
)
def post(self):
mails = ['[email protected]', '[email protected]']
res = nine_change_notice(mails)
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r'/', 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=",
"login_url": "/"
}
tornado.web.Application.__init__(self, handlers, **settings)
if __name__ == '__main__':
port = 2222
app = Application()
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(port)
tornado.ioloop.IOLoop.current().start()