-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.py
More file actions
87 lines (70 loc) · 2.23 KB
/
board.py
File metadata and controls
87 lines (70 loc) · 2.23 KB
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
import tornado.ioloop
import tornado.web
import os.path
import json
import pprint
from PIL import Image
from broadcast_api import arrange_schedule
from broadcast_api import load_schedule
from broadcast_api import edit_schedule
class BaseHandler(tornado.web.RequestHandler):
def get_current_user(self):
return self.get_secure_cookie("user")
class MainHandler(BaseHandler):
def get(self):
base_dir = os.path.dirname(__file__)
file_dir = os.path.join(base_dir,"static/img")
files = []
files.append("0.jpg")
self.set_cookie("_xsrf",self.xsrf_token)
self.render("board.html",files=files)
def post(self):
self.write("")
class Get_DB_Data(BaseHandler):
def get(self):
self.write("")
def post(self):
json_obj = tornado.escape.json_decode(self.request.body)
response_to_send = arrange_schedule(json_obj)
#pprint.pprint(response_to_send)
self.write(json.dumps(response_to_send))
class Get_txt_Data(BaseHandler):
def get(self):
self.render("")
def post(self):
json_obj = tornado.escape.json_decode(self.request.body)
response_to_send = load_schedule(json_obj)
#pprint.pprint(response_to_send)
self.write(json.dumps(response_to_send))
class Edit_txt_Data(BaseHandler):
def get(self):
self.render("")
def post(self):
json_obj = tornado.escape.json_decode(self.request.body)
response_to_send = edit_schedule(json_obj)
#pprint.pprint(response_to_send)
self.write(json.dumps(response_to_send))
class Application(tornado.web.Application):
def __init__(self):
base_dir = os.path.dirname(__file__)
settings = {
"cookie_secret": "bZJc2sWbQLKos6GkHn/VB9oXwQt8S0R0kRvJ5/xJ89E=",
"signin_url": "/signin",
"template_path":os.path.join(base_dir,"template"),
"static_path":os.path.join(base_dir,"static"),
"thumbnail_path":os.path.join(base_dir,"thumbnail"),
"debug":False,
"xsrf_cookies":True,
"autoreload":False
}
tornado.web.Application.__init__(self,[
tornado.web.url(r"/",MainHandler,name="main"),
tornado.web.url(r"/db_schedule",Get_DB_Data),
tornado.web.url(r"/txt_schedule",Get_txt_Data),
tornado.web.url(r"/txt_edit",Edit_txt_Data)
],**settings)
def main():
Application().listen(4000)
tornado.ioloop.IOLoop.instance().start()
if __name__ == "__main__":
main()