Added api for avatars support
This commit is contained in:
parent
bfce273048
commit
04749f5ffe
2
.gitignore
vendored
2
.gitignore
vendored
@ -162,3 +162,5 @@ users
|
|||||||
TASK.md
|
TASK.md
|
||||||
inline_bot.py
|
inline_bot.py
|
||||||
data/applications.json
|
data/applications.json
|
||||||
|
!data/cache/avatars/.gitkeep
|
||||||
|
data/cache/avatars/*
|
14
api_avatars.py
Normal file
14
api_avatars.py
Normal file
@ -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")
|
@ -3,3 +3,5 @@ tgcrypto>=1.2.4
|
|||||||
ujson>=5.5.0
|
ujson>=5.5.0
|
||||||
psutil>=5.9.2
|
psutil>=5.9.2
|
||||||
schedule
|
schedule
|
||||||
|
fastapi
|
||||||
|
uvicorn[standard]
|
Reference in New Issue
Block a user