Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 31 additions & 25 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,33 +244,39 @@ def before_request():
if ref_code:
session["slref"] = ref_code

@app.after_request
def after_request(res):
# not logging /static call
if (
not request.path.startswith("/static")
and not request.path.startswith("/admin/static")
and not request.path.startswith("/_debug_toolbar")
and not request.path.startswith("/git")
and not request.path.startswith("/favicon.ico")
and not request.path.startswith("/health")
):
start_time = g.start_time or time.time()
LOG.d(
"%s %s %s %s %s, takes %s",
request.remote_addr,
request.method,
request.path,
request.args,
res.status_code,
time.time() - start_time,
)
newrelic.agent.record_custom_event(
"HttpResponseStatus", {"code": res.status_code}
)
send_version_event("app")
@app.after_request
def after_request(res):
# Set proper Cache-Control for static assets to allow caching
if request.path.startswith("/static") or request.path.startswith(
"/admin/static"
):
# Allow static files to be cached for 12 hours
res.headers["Cache-Control"] = "public, max-age=43200"
return res

# not logging /static call
if (
not request.path.startswith("/_debug_toolbar")
and not request.path.startswith("/git")
and not request.path.startswith("/favicon.ico")
and not request.path.startswith("/health")
):
start_time = g.start_time or time.time()
LOG.d(
"%s %s %s %s %s, takes %s",
request.remote_addr,
request.method,
request.path,
request.args,
res.status_code,
time.time() - start_time,
)
newrelic.agent.record_custom_event(
"HttpResponseStatus", {"code": res.status_code}
)
send_version_event("app")
return res


def setup_openid_metadata(app):
@app.route("/.well-known/openid-configuration")
Expand Down