def create_app(): app = Flask(__name__) environment_config = Config.for_actual_environment() app.config.from_object(environment_config) mongo.init_app(app) set_up_sentry(environment_config) register_endpoints(app) return app
def decorated_view(*args, **kwargs): if request.method in EXEMPT_METHODS: return func(*args, **kwargs) environment_config = Config.for_actual_environment() if not environment_config.need_authorization(): return func(*args, **kwargs) token = request.headers.get('Authorization') if token != environment_config.token(): return json.dumps({ "object": {}, "errors": ["Ingreso no permitido"] }), 403 return func(*args, **kwargs)