diff --git a/api/__init__.py b/api/__init__.py index f74f503..33a5076 100644 --- a/api/__init__.py +++ b/api/__init__.py @@ -1 +1 @@ -__version__ = "1.1.3" \ No newline at end of file +__version__ = "1.1.4" \ No newline at end of file diff --git a/api/image.py b/api/image.py index eddb8e0..f99a505 100644 --- a/api/image.py +++ b/api/image.py @@ -78,7 +78,7 @@ def to_dict(self) -> ImageData: "sources": self.sources } - def to_file_response(self, raw: bool = False) -> FileResponse: + def to_file_response(self, raw: bool = False, expire: str = "300") -> FileResponse: """Returns file response object.""" if raw is False: downscaled_image = self.downscale_image() @@ -87,7 +87,7 @@ def to_file_response(self, raw: bool = False) -> FileResponse: downscaled_image, media_type="image/webp", headers = { - "Expires": "0", + "Expires": expire, "x-image-id": self.id } ) @@ -95,7 +95,7 @@ def to_file_response(self, raw: bool = False) -> FileResponse: return FileResponse( self.path, headers = { - "Expires": "0", + "Expires": expire, "x-image-id": self.id } ) \ No newline at end of file diff --git a/api/main.py b/api/main.py index f717f92..4866ec5 100644 --- a/api/main.py +++ b/api/main.py @@ -187,11 +187,11 @@ async def get_metadata(id: str): } }, ) -@limiter.limit(f"{RATE_LIMIT}/second") +@limiter.limit(f"{RATE_LIMIT}/second") async def random_image(request: Request, category: str = None, raw: bool = False): image = agac.get_random(category) - return image.to_file_response(raw) + return image.to_file_response(raw, expire="0") @app.get( "/search",