from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
from flask import request
from flask_babel import Babel
from flask_babel import lazy_gettext as _l

def get_locale():
    return request.accept_languages.best_match(app.config['LANGUAGES'])
app = Flask(__name__)
babel = Babel(app, locale_selector=get_locale)
app.config.from_object(Config)
db = SQLAlchemy(app)
migrate = Migrate(app, db)
login = LoginManager(app)
login.login_view = 'login'
login.login_message = _l('Please log in to access this page.')
from app import routes, models

from app.commands import seed_settings_command
app.cli.add_command(seed_settings_command)