def init_app(app): Bootstrap(app, css=('css/base.css', 'css/main.css', 'css/monokai.css', 'css/lib.css', 'css/timeline.css', 'css/night.css'), js=('js/main.js', 'js/highlight.js', 'js/night.js'), auth=False) Captcha(app) Error(app) App(app, json=CustomJSONEncoder) Middleware(app) Logging(app)
user = User.query.get(int(id)) return user # @login_manager.token_loader # def load_token(token): # return None return login_manager babel = register_babel() db = db csrf = CSRFProtect() bootstrap = Bootstrap( css=('styles/monokai.css', 'styles/mine.css'), js=('styles/upload.js', 'styles/forums.js', 'styles/following.js', 'styles/topic.js'), use_auth=True) captcha = Captcha() error = Error() redis_data = Redis() cache = Cache() mail = Mail() principal = Principal() login_manager = register_login() maple_app = App(json=CustomJSONEncoder) middleware = Middleware() search = Search(db=db) class AvatarCache(Avatar):
return user # @login_manager.token_loader # def load_token(token): # return None return login_manager babel = register_babel() db = db 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/following.js', 'styles/topic.js', 'tags/bootstrap-tokenfield.min.js', 'select2/js/select2.min.js'), use_auth=True) captcha = Captcha() error = Error() redis_data = Redis() cache = Cache() mail = Mail() principal = Principal() login_manager = register_login() maple_app = App(json=CustomJSONEncoder) middleware = Middleware() search = Search(db=db)
SECRET_KEY = 'asdsad' SECURITY_PASSWORD_SALT = '' SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db' MAIL_SERVER = '' MAIL_PORT = 25 MAIL_USE_TLS = True MAIL_USE_SSL = False MAIL_USERNAME = "" MAIL_PASSWORD = "" MAIL_DEFAULT_SENDER = '' def create_app(config=None): app = Flask(__name__) app.config.from_object(Config) return app app = create_app(Config()) Auth(app) LoginManager(app) Bootstrap(app, auth=True) CsrfProtect(app) Captcha(app) babel = Babel(app) if __name__ == '__main__': app.run()
# File Name: maple.py # Author: jianglin # Email: [email protected] # Created: 2018-01-25 11:52:26 (CST) # Last Update: Saturday 2018-11-11 12:35:45 (CST) # By: # Description: # ******************************************************************************** from flask_maple.bootstrap import Bootstrap from flask_maple.captcha import Captcha from flask_maple.error import Error from flask_maple.app import App from flask_maple.json import CustomJSONEncoder from flask_maple.middleware import Middleware from flask_maple.log import Logging bootstrap = Bootstrap(css=('css/main.css', 'css/monokai.css', 'css/lib.css', 'css/timeline.css'), js=('js/main.js', 'js/highlight.js', 'js/rain.js', 'js/org.js'), use_auth=False) def init_app(app): bootstrap.init_app(app) Captcha(app) Error(app) App(app, json=CustomJSONEncoder) Middleware(app) Logging(app)
from flask_wtf.csrf import CSRFProtect Auth(app) Captcha(app) CSRFProtect(app) babel = Babel(app) @babel.localeselector def get_locale(): return 'zh' login_manager = LoginManager(app) login_manager.login_view = "auth.login" login_manager.session_protection = "strong" @login_manager.user_loader def user_loader(id): User = db.Model._decl_class_registry['User'] user = User.query.get(int(id)) return user bootstrap = Bootstrap(app, use_auth=True) if __name__ == '__main__': manager.run()