-
Notifications
You must be signed in to change notification settings - Fork 10
/
application.py
54 lines (37 loc) · 1.03 KB
/
application.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
import os
import logging
from flask import Flask
from vip_system import configs
from account import instance
from vip_system import db
from vip_system import redis
from vip_system import session
APP_NAME = 'vip_system'
def create_app():
app = Flask(APP_NAME)
app.config.from_object(configs.DefaultConfig)
config_blueprint(app)
# config_logger(app)
config_db(app)
config_redis(app)
config_session(app)
return app
def config_blueprint(app):
app.register_blueprint(instance, url_prefix='/api/v1')
def config_logger(app):
log_dir = './var/log/'
log_filename = 'flask.log'
if not os.path.exists(log_dir):
os.makedirs(log_dir)
config_dict = {
'filename': log_dir + log_filename,
'format': '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
}
logging.basicConfig(**config_dict)
def config_db(app):
db.init_app(app)
def config_redis(app):
redis.init_app(app)
def config_session(app):
session.init_app(app)
app = create_app()