diff --git a/.gitignore b/.gitignore index 2e6303b..39c4532 100644 --- a/.gitignore +++ b/.gitignore @@ -161,4 +161,6 @@ users !users/.gitkeep TASK.md inline_bot.py -data/applications.json \ No newline at end of file +data/applications.json +!data/cache/avatars/.gitkeep +data/cache/avatars/* \ No newline at end of file diff --git a/api_avatars.py b/api_avatars.py new file mode 100644 index 0000000..a6f2b7b --- /dev/null +++ b/api_avatars.py @@ -0,0 +1,14 @@ +from os import path, sep +from fastapi import FastAPI, HTTPException +from fastapi.responses import FileResponse +from starlette.status import HTTP_404_NOT_FOUND +from modules.utils import configGet + +app = FastAPI(title="HoloUA Avatars API", docs_url=None, redoc_url=None, version="1.0") + +@app.get("/", response_class=FileResponse, include_in_schema=False) +async def favicon(avatar_id: str): + if path.exists(f'{configGet("cache", "locations")}{sep}avatars{sep}{avatar_id}'): + return FileResponse(f'{configGet("cache", "locations")}{sep}avatars{sep}{avatar_id}') + else: + raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="File not found") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2eb1b66..b610113 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,6 @@ pyrogram>=2.0.59 tgcrypto>=1.2.4 ujson>=5.5.0 psutil>=5.9.2 -schedule \ No newline at end of file +schedule +fastapi +uvicorn[standard] \ No newline at end of file