-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathweb.py
More file actions
executable file
·74 lines (59 loc) · 2.34 KB
/
web.py
File metadata and controls
executable file
·74 lines (59 loc) · 2.34 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
import sys
import os
import logging
import cgi
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/vendor')
os.chdir(os.path.dirname(os.path.abspath(__file__)))
#import wsgiref.simple_server
#import wsgiref.handlers
#import tornado.wsgi
import tornado.options
import tornado.ioloop
import tornado.web
import tornado.template
import tornado.database
import tornado.auth
import tornado.locale
from setting import settings
from setting import conn
from controller import main
from controller import api
from controller import auth
handlers = [
(r"/", main.FeedHandler),
(r"/item", main.ItemHandler),
(r"/edit_item", main.EditItemHandler),
(r"/submit", main.SubmitHandler),
(r"/comment", main.CommentHandler),
(r"/edit_comment", main.EditCommentHandler),
(r"/verify_email", main.VerifyEmailHandler),
(r"/invite", main.InviteHandler),
(r"/setting", main.SettingHandler),
(r"/login", main.LoginHandler),
(r"/logout", main.LogoutHandler),
(r"/api/login", api.LoginAPIHandler),
(r"/api/signup", api.SignupAPIHandler),
(r"/api/user_info", api.UserInfoAPIHandler),
(r"/api/get_feed", api.FeedAPIHandler),
(r"/api/get_item", api.ItemAPIHandler),
(r"/api/profile_img", api.ProfileImgAPIHandler),
(r"/api/like", api.LikeAPIHandler),
(r"/api/unlike", api.UnlikeAPIHandler),
(r"/api/follow", api.FollowAPIHandler),
(r"/api/unfollow", api.UnfollowAPIHandler),
(r"/api/post_status", api.PostStatusAPIHandler),
(r"/api/post_comment", api.PostCommentAPIHandler),
(r"/auth/google", auth.GoogleHandler),
(r"/auth/logout", auth.LogoutHandler),
#(r"/()", tornado.web.StaticFileHandler, dict(path=settings['static_path']+'/index.html')),
#(r"/(.*)", tornado.web.StaticFileHandler, dict(path=settings['static_path'], default_filename='index.html')),
]
if __name__ == "__main__":
tornado.locale.load_translations(os.path.join(os.path.dirname(__file__), "csv_translations"))
tornado.locale.set_default_locale("zh_CN")
tornado.options.define("port", default=8000, help="Run server on a specific port", type=int)
tornado.options.parse_command_line()
application = tornado.web.Application(handlers, **settings)
application.listen(tornado.options.options.port)
tornado.ioloop.IOLoop.instance().start()