@login_manager.user_loader def user_loader(id): user = User.query.get(int(id)) return user return login_manager babel = register_babel() db = SQLAlchemy() admin = Admin(name='HonMaple', template_mode='bootstrap3') avatar = Avatar() csrf = CsrfProtect() bootstrap = Bootstrap( css=('styles/monokai.css', 'styles/mine.css', 'tags/css/bootstrap-tokenfield.css', 'select2/css/select2.min.css'), js=('styles/upload.js', 'styles/forums.js', 'styles/mine.js', 'styles/topic.js', 'tags/bootstrap-tokenfield.min.js', 'select2/js/select2.min.js'), use_auth=True) captcha = Captcha() error = Error() redis_data = Redis(decode_responses=True) cache = Cache() mail = MapleMail() principal = Principal() login_manager = register_login() maple_app = App(json=CustomJSONEncoder) middleware = Middleware()
return request.accept_languages.best_match(['zh', 'en']) @babel.timezoneselector def get_timezone(): return 'UTC' return babel db = db csrf = CSRFProtect() cache = Cache() babel = register_babel() mail = Mail() login_manager = register_login() redis_data = Redis() middleware = Middleware() maple_app = App(json=CustomJSONEncoder) def init_app(app): db.init_app(app) csrf.init_app(app) cache.init_app(app) babel.init_app(app) mail.init_app(app) login_manager.init_app(app) redis_data.init_app(app) middleware.init_app(app) maple_app.init_app(app) register_maple(app)
# Description: # ******************************************************************************** from flask_maple.redis import Redis from flask_maple.mail import Mail from flask_maple.views import QuickApi from flask_wtf.csrf import CSRFProtect from flask_caching import Cache from flask_maple.models import db from flask_cors import CORS from . import maple, login, babel db = db csrf = CSRFProtect() cache = Cache() mail = Mail() redis = Redis() api = QuickApi() cors = CORS() def init_app(app): api.init_app(app) db.init_app(app) csrf.init_app(app) cors.init_app(app) cache.init_app(app) mail.init_app(app) redis.init_app(app) maple.init_app(app) login.init_app(app) babel.init_app(app)