-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.py
42 lines (32 loc) · 1.17 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Main application script
Created by: Rui Carmo
License: MIT (see LICENSE for details)
"""
import os, sys, json, logging, logging.config
# Make sure our bundled libraries take precedence
sys.path.insert(0,os.path.join(os.path.dirname(os.path.abspath(__file__)),'lib'))
import bottle, config, utils
# read configuration file
config.settings = utils.get_config(os.path.join(utils.path_for('etc'),'config.json'))
# Set up logging
logging.config.dictConfig(dict(config.settings.logging))
log = logging.getLogger()
if __name__ == "__main__":
if config.settings.debug:
if 'BOTTLE_CHILD' not in os.environ:
log.debug('Using reloader, spawning first child.')
else:
log.debug('Child spawned.')
if not config.settings.debug or ('BOTTLE_CHILD' in os.environ):
log.info("Setting up application.")
import api, routes, controllers
log.info("Serving requests.")
bottle.run(
port = config.settings.server.http.port,
host = config.settings.server.http.bind_address,
debug = config.settings.debug,
reloader = config.settings.reloader
)