-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
67 lines (48 loc) · 1.51 KB
/
main.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
import tornado.ioloop
import tornado.web
import todo
import mpc
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello World")
class TestHandler(tornado.web.RequestHandler):
def get(self, name):
self.write("Hello %s" % name)
class MpcPlay(tornado.web.RequestHandler):
def get(self):
mpc.play()
self.write("Done")
class MpcPause(tornado.web.RequestHandler):
def get(self):
mpc.pause()
self.write("Done")
class TodoRemindMe(tornado.web.RequestHandler):
def post(self):
message = self.request.body
todo.task(message)
self.write("Done")
class TodoRemindMeAtStation(tornado.web.RequestHandler):
def post(self):
message = self.request.body
todo.task_station(message)
self.write("Done")
class TodoRemindMeAtCity(tornado.web.RequestHandler):
def post(self):
message = self.request.body
todo.task_city(message)
self.write("Done")
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
(r"/test/([a-z]+)", TestHandler),
(r"/mpc/play", MpcPlay),
(r"/mpc/pause", MpcPause),
(r"/todo/remind/me", TodoRemindMe),
(r"/todo/remind/me/at/country", TodoRemindMe),
(r"/todo/remind/me/at/station", TodoRemindMeAtStation),
(r"/todo/remind/me/at/city", TodoRemindMeAtCity),
])
if __name__ == "__main__":
app = make_app()
app.listen(5000)
tornado.ioloop.IOLoop.current().start()