diff --git a/api_avatars.py b/api_avatars.py deleted file mode 100644 index 85fcf62..0000000 --- a/api_avatars.py +++ /dev/null @@ -1,40 +0,0 @@ -from os import makedirs, path, sep -from fastapi import FastAPI, HTTPException -from fastapi.responses import FileResponse, JSONResponse, Response -from starlette.status import HTTP_404_NOT_FOUND -from modules.utils import configGet - -makedirs(f'{configGet("cache", "locations")}{sep}avatars', exist_ok=True) - -app = FastAPI(title="HoloUA Avatars API", docs_url=None, redoc_url=None, version="1.0") - - -@app.get("/check", response_class=JSONResponse, include_in_schema=False) -@app.head("/check", response_class=JSONResponse, include_in_schema=False) -async def check(): - return JSONResponse({"detail": "I'm alright, thank you"}) - - -@app.get("/", response_class=FileResponse, include_in_schema=False) -async def avatar_get(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}', - media_type="image/jpg", - ) - else: - raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="File not found") - - -@app.head("/", response_class=Response, include_in_schema=False) -async def avatar_head(avatar_id: str): - if path.exists(f'{configGet("cache", "locations")}{sep}avatars{sep}{avatar_id}'): - return Response( - headers={ - "Content-Length": path.getsize( - f'{configGet("cache", "locations")}{sep}avatars{sep}{avatar_id}' - ) - } - ) - else: - raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail="File not found") diff --git a/requirements.txt b/requirements.txt index 3d0e16c..38333d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,7 @@ -aiocsv==1.2.3 +aiocsv==1.2.4 aiofiles~=23.1.0 APScheduler~=3.10.1 convopyro==0.5 -fastapi~=0.95.0 ftfy~=6.1.1 psutil==5.9.4 polyglot~=16.7.4 @@ -13,7 +12,6 @@ Pyrogram~=2.0.103 python_dateutil==2.8.2 pykeyboard==0.1.5 requests==2.28.2 -starlette==0.26.1 tgcrypto==1.2.5 ujson~=5.7.0 xmltodict==0.13.0 \ No newline at end of file