Frontend: add dynamic color from user avatar.

Backend: add image proxy
This commit is contained in:
Kentai Radiquum 2024-04-26 03:20:13 +05:00
parent 76bb133955
commit 1a83a80e07
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
7 changed files with 45 additions and 6 deletions

View file

@ -2,7 +2,9 @@ from typing import TypedDict
from typing import Union
import requests
from fastapi import APIRouter
from fastapi import Request
from fastapi import Response
class Endpoints(TypedDict):
@ -67,3 +69,17 @@ async def apiRequest(
if r.status_code != 200:
return {"error": r.text}
return r.json()
router = APIRouter()
@router.get(
"/image",
responses={200: {"content": {"image/jpg": {}, "image/png": {}}}},
response_class=Response,
)
async def imageProxy(url: str):
type = url.split(".")[-1]
response: bytes = requests.get(url).content
return Response(content=response, media_type=f"image/{type}")