forked from evolvedlight/pydashie
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
45 lines (36 loc) · 1.07 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: et:ts=4:sw=4:
"""
Main application script
Created by: Rui Carmo
License: MIT (see LICENSE.md for details)
"""
import os, sys, json, logging
# Make sure our bundled libraries take precedence
sys.path.insert(0,os.path.join(os.path.dirname(os.path.abspath(__file__)),'lib'))
import utils, bottle
from config import settings
log = logging.getLogger()
if os.path.dirname(__file__):
os.chdir(os.path.dirname(__file__))
if settings.reloader:
if "BOTTLE_CHILD" not in os.environ:
log.debug("Using reloader, spawning first child.")
else:
log.debug("Child spawned.")
# Bind routes
if not settings.reloader or ("BOTTLE_CHILD" in os.environ):
log.info("Setting up application.")
import routes
if __name__ == "__main__":
log.info("Serving requests.")
bottle.run(
port = settings.http.port,
host = settings.http.bind_address,
debug = settings.debug,
reloader = settings.reloader
)
else:
log.info("Running under uWSGI")
app = bottle.default_app()