-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
51 lines (39 loc) · 1.32 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
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import logging
from logging import Formatter
from logging.handlers import RotatingFileHandler
# import configs
try:
import ConfigParser
except:
import configparser
app = Flask(__name__)
app.config['SECRET_KEY'] = 'SRSS4Life'
# ==============================#
# Logging info
# ==============================#
handler = RotatingFileHandler('./logs/application.log', maxBytes=10000, backupCount=1)
handler.setLevel(logging.DEBUG)
handler.setFormatter(Formatter('[%(asctime)s] :: %(levelname)s :: MODULE %(module)s :: lINE %(lineno)d :: %(message)s'))
app.logger.addHandler(handler)
# ==============================#
# Configuration files
# ==============================#
try:
config = ConfigParser.ConfigParser()
except:
# import configparser
config = configparser.ConfigParser()
config.read('server.conf')
environment = config.get('GLOB', 'environment')
app.logger.info('Running in {} mode'.format(environment))
if environment == 'DEV':
DEBUG = True
else:
DEBUG = False
# ==============================#
# Set up the data base for recording when we copy and write to the database.
# ==============================#
app.config['SQLALCHEMY_DATABASE_URI'] = config.get(environment, 'database_url') # !!! Change me on Production
db = SQLAlchemy(app)