-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapi.py
133 lines (105 loc) · 4.05 KB
/
api.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
from tornado import ioloop
from tornado import web
from tornado import options
from app.user_auth import UserAuth
from app.user_auth import UserReminder
from app.user_deauth import UserDeauth
from app.showtimes import CreateShowtimeHandler, ListShowtimesHandler,\
ShowtimeAccessTokens, ShowtimeKeys
from app.promotion_keys import PromotionKeysHandler
from app.services_auth.google_auth import GoogleAuth
from app.services_auth.facebook_auth import FacebookAuth
from app.services_auth.spotify_auth import SpotifyAuth
from app.services_auth.twitter_auth import TwitterAuth
from app.services_auth.reddit_auth import RedditAuth
from app.services_auth.tumblr_auth import TumblrAuth
from app.services_auth.instagram_auth import InstagramAuth
from lib import config
# Set basic options
options.define("port", default=6060, type=int, help="What port to run on")
options.define("debug", default=False, type=bool, help="Debug Mode")
options.define("config", default='dev',
type=str, help="Section of config file to read")
class MainHandler(web.RequestHandler):
def get(self):
self.render("home.html")
class TestHandler(web.RequestHandler):
def get(self):
self.render("index.html")
class SignupHandler(web.RequestHandler):
def get(self):
self.render("signup.html")
class PolicyHandler(web.RequestHandler):
def get(self):
self.render("policy.html")
class AboutHandler(web.RequestHandler):
def get(self):
self.render("about.html")
class CloseWindow(web.RequestHandler):
def get(self):
self.render("closewindow.html")
class UserUnauth(web.RequestHandler):
def get(self):
self.render("deauth.html")
class UserUnauth2(web.RequestHandler):
def get(self):
self.render("deauth2.html")
class UserUnauth3(web.RequestHandler):
def get(self):
self.render("deauth3.html")
class NewsHandler(web.RequestHandler):
def get(self):
self.render("news.html")
if __name__ == "__main__":
options.parse_command_line()
port = options.options.port
debug = options.options.debug
config.read_config(options.options.config)
oauth_creds = {}
services = 'google facebook spotify twitter tumblr instagram reddit'
CONFIG = config.CONFIG
for service in services.split():
oauth_creds[service + '_oauth'] = {
"key": CONFIG.get("{}_client_id".format(service)),
"secret": CONFIG.get("{}_client_secret".format(service)),
}
app = web.Application(
[
(r'/', MainHandler),
(r'/test', TestHandler),
(r'/news', NewsHandler),
(r'/signup', SignupHandler),
(r'/leave', UserUnauth),
(r'/leave2', UserUnauth2),
(r'/fullcancel', UserUnauth3),
(r'/policy', PolicyHandler),
(r'/about', AboutHandler),
(r'/auth/google', GoogleAuth),
(r'/auth/facebook', FacebookAuth),
(r'/auth/spotify', SpotifyAuth),
(r'/auth/twitter', TwitterAuth),
(r'/auth/reddit', RedditAuth),
(r'/auth/tumblr', TumblrAuth),
(r'/auth/instagram', InstagramAuth),
(r'/auth/close', CloseWindow),
(r'/auth/deauth', UserDeauth),
(r'/api/reminders', UserReminder),
(r'/user/info', UserAuth),
(r'/api/showtimes', ListShowtimesHandler),
(r'/api/showtimes/keys', ShowtimeKeys),
(r'/api/showtimes/access_tokens', ShowtimeAccessTokens),
(r'/api/showtimes/create', CreateShowtimeHandler),
(r'/api/promotionkeys', PromotionKeysHandler),
(r"/favicon.ico", web.StaticFileHandler, {"path": ""}),
],
template_path="./templates/",
static_path="./static/",
debug=debug,
cookie_secret=CONFIG.get('cookie_secret'),
base_url=CONFIG.get('base_url'),
**oauth_creds
)
app.listen(port, protocol='https')
print("Using base url: " + CONFIG.get('base_url'))
print("Listening on port: " + str(port))
ioloop.IOLoop.current().start()