Compare commits
3 commits
5badcd8a9f
...
fb84e2f8f0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fb84e2f8f0 | ||
![]() |
389b1a8320 | ||
![]() |
4f136cff5b |
3 changed files with 10 additions and 12 deletions
14
app.py
14
app.py
|
@ -72,12 +72,11 @@ async def cloudflare(zone_id: str, x_token: Union[str, None] = Header()):
|
||||||
json = result.json()
|
json = result.json()
|
||||||
res = JSONResponse(json)
|
res = JSONResponse(json)
|
||||||
if "data" in json and not json["errors"]:
|
if "data" in json and not json["errors"]:
|
||||||
res.headers["Cache-Control"] = f"public, max-age=60, s-maxage=60"
|
pass
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=60"
|
|
||||||
else:
|
else:
|
||||||
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||||
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0"
|
res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=0"
|
res.headers["CDN-Cache-Control"] = f"max-age=15"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.get("/api/cloudflare2")
|
@app.get("/api/cloudflare2")
|
||||||
|
@ -106,12 +105,11 @@ async def cloudflare2(zone_id: str, x_token: Union[str, None] = Header()):
|
||||||
json = result.json()
|
json = result.json()
|
||||||
res = JSONResponse(json)
|
res = JSONResponse(json)
|
||||||
if "data" in json and not json["errors"]:
|
if "data" in json and not json["errors"]:
|
||||||
res.headers["Cache-Control"] = f"public, max-age=60, s-maxage=60"
|
pass
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=60"
|
|
||||||
else:
|
else:
|
||||||
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
res.status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||||
res.headers["Cache-Control"] = f"public, max-age=0, s-maxage=0"
|
res.headers["Cache-Control"] = f"public, max-age=15, s-maxage=15"
|
||||||
res.headers["CDN-Cache-Control"] = f"max-age=0"
|
res.headers["CDN-Cache-Control"] = f"max-age=15"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
fastapi[standard]==0.115.7
|
fastapi[standard]==0.115.8
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue