def create_app(config_object=None): app = Flask(__name__) app.config.from_object(config_object) from db import db as _db _db.init_app(app) # oauth init from oauth import oauth oauth.init_app(app) # register uuid converter from flask.ext.uuid import FlaskUUID FlaskUUID(app) # register error handlers import errors errors.init_error_handlers(app) # register loggers import loggers if app.debug is False: loggers.init_app(app) import login login.init_oauth_providers(app) # register blueprints from oauth.views import oauth_bp from login.views import login_bp from review.views import review_bp from user.views import user_bp from client.views import client_bp app.register_blueprint(oauth_bp, url_prefix='/oauth') app.register_blueprint(login_bp, url_prefix='/login') app.register_blueprint(review_bp, url_prefix='/review') app.register_blueprint(user_bp, url_prefix='/user') app.register_blueprint(client_bp, url_prefix='/client') return app
"access", "refresh", ] # allow blacklisting for access and refresh tokens app.secret_key = os.environ.get( 'secret_key') # could do app.config['JWT_SECRET_KEY'] if we prefer patch_request_class(app, 10 * 1024 * 1024) # 10bit * 1024 = 10kb * 1024 = 10MB configure_uploads(app, image_upload.IMAGE_SET) api = Api(app) jwt = JWTManager(app) migrate = Migrate(app, db) db.init_app(app) ma.init_app(app) oauth.init_app(app) @app.errorhandler(ValidationError) def handle_marshmallow_validation(err): return jsonify(err.messages), 400 # This method will check if a token is blacklisted, and will be called automatically when blacklist is enabled @jwt.token_in_blacklist_loader def check_if_token_in_blacklist(decrypted_token): return ( decrypted_token["jti"] in BLACKLIST ) # Here we blacklist particular JWTs that have been created in the past.
from app import app as application from db import db from marsh import io from oauth import oauth db.init_app(application) io.init_app(application) oauth.init_app(application) @application.before_first_request def create_tables(): db.create_all()