-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
65 lines (56 loc) · 2.13 KB
/
app.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
#!/usr/bin/env python
"""
Main server script.
"""
import settings
## Import Mongodb packages
from pymongo import MongoClient
import socket
from mongoengine import *
import os
## Import Tornado packages
from tornado.escape import json_encode, json_decode, url_escape
import tornado.ioloop
from tornado.auth import GoogleOAuth2Mixin
from tornado.gen import coroutine
from tornado.web import RequestHandler, Application, authenticated
## Import Route Handlers
from routes.BaseHandler import BaseHandler
from routes.IndexHandler import IndexHandler
from routes.OnboardingHandler import OnboardingHandler
from routes.LearnMoreHandler import LearnMoreHandler
from routes.WebsiteCreatorHandler import WebsiteCreatorHandler
from routes.WebsiteEditorHandler import WebsiteEditorHandler
from routes.AuthHandler import AuthLoginHandler, AuthLogoutHandler, SessionHandler
from routes.UserHandler import UserHandler
from routes.VCMatcherHandler import VCMatcherHandler
## Main Configs
if __name__ == "__main__":
db_host = os.environ.get("DB_PORT_27017_TCP_ADDR", "localhost")
client = MongoClient(db_host, 27017)
database = client.min_bench
connect("min_bench", host=db_host)
settings_dict = {
"static_path" : settings.STATIC_PATH,
"template_path" : settings.TEMPLATE_PATH,
"login_url" : "/auth/login/",
"debug": settings.DEBUG,
"cookie_secret": settings.COOKIE_SECRET,
"google_oauth" : { "key" : settings.GAUTH_CLIENT_ID,
"secret" : settings.GAUTH_CLIENT_SECRET },
"database" : database
}
application = Application([
(r"/", IndexHandler),
(r"/auth/login/?", AuthLoginHandler),
(r"/auth/logout/?", AuthLogoutHandler),
(r"/auth/session/?", SessionHandler),
(r"/learn/?", LearnMoreHandler),
(r"/main/?", OnboardingHandler),
(r"/edit/?", UserHandler),
(r"/vc-matcher", VCMatcherHandler),
(r"/websitecreator/?", WebsiteCreatorHandler),
(r"/websiteeditor/?", WebsiteEditorHandler),
], **settings_dict)
application.listen(settings.PORT)
io_loop = tornado.ioloop.IOLoop.instance().start()