Only cache 200 responses
Some checks failed
Amarillo/amarillo-gitea/amarillo-gtfs-export/pipeline/head There was a failure building this commit
Some checks failed
Amarillo/amarillo-gitea/amarillo-gtfs-export/pipeline/head There was a failure building this commit
This commit is contained in:
parent
eba7967c90
commit
a7311b9152
|
|
@ -62,6 +62,7 @@ async def get_file(region_id: str, requesting_user: User = Depends(get_current_u
|
|||
# logger.info("Returning new response")
|
||||
response = requests.get(f"{config.generator_url}/region/{region_id}/gtfs/")
|
||||
# cache response
|
||||
if response.status_code == 200:
|
||||
with open(file_path, "wb") as file:
|
||||
file.write(response.content)
|
||||
|
||||
|
|
@ -88,12 +89,13 @@ async def get_file(region_id: str, format: str = 'protobuf', requesting_user: Us
|
|||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=message)
|
||||
|
||||
if is_cached_1m(file_path):
|
||||
logger.info("Returning cached response")
|
||||
# logger.info("Returning cached response")
|
||||
return FileResponse(file_path)
|
||||
|
||||
logger.info("Returning new response")
|
||||
# logger.info("Returning new response")
|
||||
response = requests.get(f"{config.generator_url}/region/{region_id}/gtfs-rt/?format={format}")
|
||||
# cache response
|
||||
if response.status_code == 200:
|
||||
with open(file_path, "wb") as file:
|
||||
file.write(response.content)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "amarillo-gtfs-exporter"
|
||||
version = "0.0.2"
|
||||
version = "0.0.4"
|
||||
dependencies = [
|
||||
"amarillo"
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue