Skip to content

Commit

Permalink
after_request/before_request applied only to blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Feb 27, 2024
1 parent 3860963 commit 1ccffdc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mwdb/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class HashConverter(BaseConverter):
app.register_blueprint(static_blueprint)


@app.before_request
@api.blueprint.before_request
def assign_request_id():
g.request_id = token_hex(16)
g.request_start_time = datetime.utcnow()
Expand All @@ -152,7 +152,7 @@ def assign_request_id():
)


@app.after_request
@api.blueprint.after_request
def log_request(response):
if hasattr(g, "request_start_time"):
response_time = datetime.utcnow() - g.request_start_time
Expand Down Expand Up @@ -186,7 +186,7 @@ def log_request(response):
return response


@app.before_request
@api.blueprint.before_request
def require_auth():
if request.method == "OPTIONS":
return
Expand Down Expand Up @@ -221,7 +221,7 @@ def require_auth():
raise Forbidden("User has been disabled.")


@app.before_request
@api.blueprint.before_request
def apply_rate_limit():
apply_rate_limit_for_request()

Expand Down

0 comments on commit 1ccffdc

Please sign in to comment.