-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeep_app.py
More file actions
45 lines (33 loc) · 823 Bytes
/
deep_app.py
File metadata and controls
45 lines (33 loc) · 823 Bytes
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
"""
Flask App.
"""
import logging
import logging.config
from cfg.flask_cfg import Flask
from cfg.main_cfg import CFG
from utils.exception import Error
from routes import (
dream,
styles
)
def create_app():
""" load config """
cfg = CFG()
""" create app """
app = Flask(cfg.NAME)
app.config.from_cfg(cfg)
""" blueprints """
app.register_blueprint(dream.create_blueprint(cfg))
app.register_blueprint(styles.create_blueprint(cfg))
""" handlers """
@app.errorhandler(Error)
def error_handler(err):
# custom errors
app.logger.exception(err)
return err.as_res()
@app.errorhandler(Exception)
def exception_handler(exc):
# other exceptions
app.logger.exception(exc)
return ('Unknown Error', 500)
return app