mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 17:39:41 +05:00
Frontend: add dynamic color from user avatar.
Backend: add image proxy
This commit is contained in:
parent
76bb133955
commit
1a83a80e07
7 changed files with 45 additions and 6 deletions
|
@ -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}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue