fix cors and caching of counter

Signed-off-by: Ari Archer <ari@ari.lt>
This commit is contained in:
Arija A. 2024-06-14 10:37:05 +03:00
parent 741bc64237
commit 546b3bc1d9

View file

@ -260,7 +260,8 @@ def favicon() -> Response:
@views.get("/counter.svg")
def counter() -> flask.Response:
"""counter"""
return flask.Response(
r = flask.Response(
util.text2svg(
text=str(models.Counter.first().inc().count),
fill=flask.request.args.get("fill", "#fff"),
@ -273,6 +274,15 @@ def counter() -> flask.Response:
mimetype="image/svg+xml",
)
r.headers["Access-Control-Allow-Origin"] = "*"
r.headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS, HEAD"
r.headers["Expires"] = "Thu, 01 Jan 1970 00:00:00 GMT"
r.headers["Cache-Control"] = (
"max-age=0, no-cache, must-revalidate, proxy-revalidate"
)
return r
@views.get("/badge.png")
def badge() -> Response: