forked from Prescrypto/WPCI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
53 lines (46 loc) · 1.91 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
#python
import os
import logging
#web app
from tornado.web import Application, FallbackHandler, StaticFileHandler
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
#internal
from handlers import routes
from oauthApi import oauth_app
import config as conf
# Load Logging definition
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger('tornado-info')
DOCS_BASE_PATH = "docs/"
API_BASE_PATH = "api/v1/"
LISTEN_PORT = conf.LISTEN_PORT
cwd = os.getcwd() # used by static file server
# execute asynchronously action
# When running locally, disable OAuthlib's HTTPs verification.
# ACTION ITEM for developers:
# When running in production *do not* leave this option enabled.
#os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
'''Initializing the application with routes'''
web_app = Application([
(r"/"+API_BASE_PATH+"documents/links/([^/]+)", routes.Links),
(r"/"+API_BASE_PATH+"documents/([^/]+)", routes.Documents),
(r"/"+API_BASE_PATH+"documents/pdf/([^/]+)", routes.RenderDocToPDF),
(r"/"+API_BASE_PATH+"documents", routes.PostWpNda),
(r"/"+API_BASE_PATH+"login", routes.AuthLoginHandler),
(r"/"+API_BASE_PATH+"signin", routes.RegisterUser),
(r"/"+API_BASE_PATH+"register", routes.RegisterUserByEmail),
(r"/"+API_BASE_PATH+"payments/webhook/confirmation", routes.WebhookConfirm),
(r"/"+API_BASE_PATH+"pdf/(.*)", FallbackHandler, dict(fallback=oauth_app)),
(r"/"+DOCS_BASE_PATH+"(.*)", FallbackHandler, dict(fallback=oauth_app)),
(r"/", FallbackHandler, dict(fallback=oauth_app)),
(r"/(.*\.css)", StaticFileHandler, {"path": cwd}),
(r"/(.*\.js)", StaticFileHandler, {"path": cwd}),
(r"/(.*\.svg)", StaticFileHandler, {"path": cwd}),
(r"/(.*\.txt)", StaticFileHandler, {"path": cwd}),
(r'.*', routes.APINotFoundHandler)],
debug=True)
httpServer = HTTPServer(web_app)
httpServer.listen(LISTEN_PORT)
httpServer.start()
IOLoop.instance().start()