luniebox/application/app.py
2022-02-06 10:19:03 +01:00

32 lines
924 B
Python

import sys
from flask import Flask
import logging
from luniebox import luniebox
from api import api
from pages import pages
app = Flask(__name__)
app.register_blueprint(api, url_prefix='/api')
app.register_blueprint(pages)
loglevel = 'INFO'
if luniebox.get_setting('logging', 'level'):
loglevel = luniebox.get_setting('logging', 'level')
logger = logging.getLogger('luniebox')
logger.setLevel(logging._nameToLevel[loglevel])
logFormatter = logging.Formatter(
style='{', datefmt='%Y-%m-%d %H:%M:%S', fmt='{asctime} {levelname}: {message}')
logstdoutHandler = logging.StreamHandler(sys.stdout)
logstdoutHandler.setFormatter(logFormatter)
logger.addHandler(logstdoutHandler)
if __name__ != '__main__':
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
if __name__ == "__main__":
app.run(host='0.0.0.0')