mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-29 17:39:41 +05:00
split to modules. ADD index page.
This commit is contained in:
parent
025ef2be93
commit
c82b6e7265
11 changed files with 120 additions and 53 deletions
41
backend/modules/proxy.py
Normal file
41
backend/modules/proxy.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from typing import Union
|
||||
|
||||
import requests
|
||||
from fastapi import Request
|
||||
|
||||
API_URL = "https://api.anixart.tv"
|
||||
ENDPOINTS = {
|
||||
"release": f"{API_URL}/release",
|
||||
"profile": f"{API_URL}/profile",
|
||||
"filter": f"{API_URL}/filter",
|
||||
}
|
||||
USER_AGENT = "AnixartApp/8.2.1-23121216 (Android 11; SDK 30; arm64-v8a;)"
|
||||
|
||||
|
||||
async def apiRequest(
|
||||
# noqa: E501
|
||||
request: Request = None,
|
||||
endpoint: str = "",
|
||||
path: str = "",
|
||||
query: str = "",
|
||||
data: Union[None, str, dict] = None,
|
||||
):
|
||||
|
||||
headers = {
|
||||
"User-Agent": USER_AGENT,
|
||||
"Content-Type": "application/json; charset=UTF-8",
|
||||
}
|
||||
|
||||
if request.method == "POST":
|
||||
r = requests.post(
|
||||
# noqa: E501
|
||||
f"{endpoint}/{path}{query}",
|
||||
headers=headers,
|
||||
data=data,
|
||||
)
|
||||
else:
|
||||
r = requests.get(f"{endpoint}/{path}{query}", headers=headers)
|
||||
|
||||
if r.status_code != 200:
|
||||
return {"error": r.text}
|
||||
return r.json()
|
Loading…
Add table
Add a link
Reference in a new issue