-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (42 loc) · 1.91 KB
/
Copy pathmain.py
File metadata and controls
47 lines (42 loc) · 1.91 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
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from loginHandler import LoginHandler
from sqlalchemy.orm import scoped_session, sessionmaker
from tornado.options import define, options
from Database.models import engine
from AppointmentsAskHandler import AskAppointment
from Database.tables import Activity,ActivityParticipate,Appointment,AppointmenmtEntry,AppointmentRegister,Estimation,Style,User
from AppointmentHandler import CreateAppointment, RegistAppointment
from RegisterHandler import RegisterHandler
from ActivityHandler import ActivityCommit, ActivityJoin
from ActivityAskHandler import AskActivity
define("port", default=800, help="run on the given port", type=int)
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/appointment/create", CreateAppointment),
(r"/appointment/ask", AskAppointment),
(r"/appointment/register", RegistAppointment),
(r"/login",LoginHandler),
(r"/regist", RegisterHandler),
(r"/Activity/create", ActivityCommit),
(r"/Activity/ask", AskActivity),
(r"/Activity/register", ActivityJoin),
]
tornado.web.Application.__init__(self, handlers)
self.db = scoped_session(sessionmaker(bind=engine,
autocommit=False, autoflush=True,
expire_on_commit=False))
# session负责执行内存中的对象和数据库表之间的同步工作 Session类有很多参数,使用sessionmaker是为了简化这个过程
if __name__ == "__main__":
print "HI,I am in main "
tornado.options.parse_command_line()
Application().listen(options.port)
try:
tornado.ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
tornado.ioloop.IOLoop.instance().stop()