def create_app(config_object): application = Flask(__name__) application.logger.removeHandler(default_handler) application.config.from_object(config_object) api.init_app(application) register_commands(application) return application
def create_app(config): app = Flask(__name__) app.config.from_object(config) db.init_app(app) api.init_app(app) jwt_manager.init_app(app) return app
def create_app(): application = Flask(__name__) application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI # application.config['BABEL_DEFAULT_LOCALE'] = 'ru-ru' application.config['SECRET_KEY'] = SECRET_KEY application.permanent_session_lifetime = timedelta(minutes=30) Triangle(application) assets.init_app(application) api.init_app(application) api.application = application db.init_app(application) admin.init_app(application) login_manager.init_app(application) application.db = db application.api = api babel = Babel(application) @babel.localeselector def get_locale(): return request.accept_languages.best_match(["ru"]) init_logging(application) return application
def init_app(application): from resources import api from assets import assets from applications.security.auth import login_manager from security import security application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI application.config['SECURITY_TOKEN_AUTHENTICATION_HEADER'] = ( "AUTHORIZATION") application.config['SECURITY_REMEMBER_SALT'] = "SALT123123123" application.config['SQLALCHEMY_ECHO'] = True application.config['SECRET_KEY'] = SECRET_KEY application.permanent_session_lifetime = timedelta(minutes=30) Triangle(application) assets.init_app(application) api.init_app(application) api.application = application db.init_app(application) login_manager.init_app(application) security.init_app(application) application.db = db application.api = api if IS_PROD: init_logging(application) return application
def create_app(config_class=Config): app.config.from_object(config_class) db.init_app(app) migrate.init_app(app, db) # db.create_all() from resources import api api.init_app(app) return app
def config_extensions(app): db.init_app(app) api.init_app(app) bcrypt.init_app(app) # 配置验证, HTTP BASE Authenticate @auth.verify_password def verify_password(username_or_token, password): # first tyr to authenticate by token user = User.virify_auth_token(username_or_token) if not user: # try to authenticate by token user = User.query.filter_by(username=username_or_token).first() # user = User.get_user_by_name(username_or_token) if not user or not user.verify_password(password): return False g.user = user return True
def create_app(test_config=None): # create and configure the app app = Flask(__name__) if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile('config.cfg', silent=True) else: # load the test config if passed in app.config.from_pyfile(test_config) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass api.init_app(app) db.init_app(app) ma.init_app(app) migrate.init_app(app, db) return app
from flask_sqlalchemy import SQLAlchemy from flask_jwt_extended import JWTManager, jwt_required, create_access_token, get_jwt_identity from flask_restplus import Resource, Api from resources import api import datetime app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['JWT_EXPIRATION_DELTA'] = datetime.timedelta(minutes=20) app.config['JWT_SECRET_KEY'] = 'team_fancyfancy' app.config['PROPAGATE_EXCEPTIONS'] = True app.config['SWAGGER_UI_DOC_EXPANSION'] = 'list' app.secret_key = 'team_fancyfancy' db.init_app(app) jwt.init_app(app) api.init_app(app) jwt._set_error_handler_callbacks(api) @app.before_first_request def create_tables(): db.create_all() if __name__ == '__main__': # app = create_app() app.run(port=5000, debug=True)
def register_extension(app): db.init_app(app) api.init_app(app) jwt.init_app(app)