Files
myapp-full/myapp/__init__.py

67 lines
1.3 KiB
Python
Raw Normal View History

__author__ = 'RemiZOffAlex'
__copyright__ = '(c) RemiZOffAlex'
__email__ = 'remizoffalex@mail.ru'
import config
import logging
from flask import Flask
from logging.handlers import RotatingFileHandler
app = Flask(__name__)
app.config.from_object(config.CONFIG)
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
# Логирование
2019-04-26 15:38:41 +03:00
handler = RotatingFileHandler(
app.config['LOG_FILE'],
maxBytes=app.config['LOG_FILE_SIZE']*1024*1024,
2019-04-26 15:38:41 +03:00
backupCount=1
)
handler.setLevel(logging.INFO)
formatter = logging.Formatter(app.config['LONG_LOG_FORMAT'])
handler.setFormatter(formatter)
app.logger.addHandler(handler)
2019-04-26 19:38:23 +03:00
from . import lib, models
2020-08-17 19:57:37 +03:00
2019-04-26 19:38:23 +03:00
@app.context_processor
def inject_data():
result = {}
result['user'] = None
if lib.get_user():
result['user'] = lib.get_user()
return result
2020-08-17 19:57:37 +03:00
2019-04-26 19:38:23 +03:00
@app.teardown_appcontext
def shutdown_session(exception=None):
models.db_session.close_all()
# API
2020-08-17 19:57:37 +03:00
from . import ns_api # noqa F401
2019-04-26 19:38:23 +03:00
# Авторизация
2020-08-17 19:57:37 +03:00
from . import ns_login # noqa F401
2019-04-26 19:38:23 +03:00
2020-02-16 22:58:39 +03:00
# Заметки
2020-08-17 19:57:37 +03:00
from . import ns_note # noqa F401
2020-02-16 22:58:39 +03:00
2020-02-08 05:05:10 +03:00
# Статьи
2020-08-17 19:57:37 +03:00
from . import ns_page # noqa F401
2020-02-08 05:05:10 +03:00
2019-04-26 19:38:23 +03:00
# Профиль
2020-08-17 19:57:37 +03:00
from . import ns_profile # noqa F401
2019-04-26 19:38:23 +03:00
2019-10-27 19:40:03 +03:00
# Метки
2020-08-17 19:57:37 +03:00
from . import ns_tag # noqa F401
2019-10-27 19:40:03 +03:00
# Пользователи
2020-08-17 19:57:37 +03:00
from . import ns_user # noqa F401
2020-08-17 19:57:37 +03:00
from . import views # noqa F401