Small fixes

This commit is contained in:
2024-05-10 16:44:46 +04:00
parent a45c2dfee2
commit fd5b19e6a9
12 changed files with 94 additions and 61 deletions

View File

@@ -1,20 +1,24 @@
from fastapi import APIRouter, Depends, HTTPException, UploadFile
from fastapi import APIRouter, HTTPException, UploadFile
from database import *
from file_handler import *
router = APIRouter(prefix="/files", tags=["Files"])
files_router = APIRouter(prefix="/files", tags=["Files"])
@router.post("/torrent", response_model=str)
@files_router.post("/torrent", response_model=str)
async def upload_torrent(torrent: UploadFile):
try: return await save_torrent_file(torrent)
except Exception as ex:
try:
return await save_torrent_file(torrent)
except Exception as ex:
print(ex)
raise HTTPException(500)
@router.post("/cover", response_model=str)
@files_router.post("/cover", response_model=str)
async def upload_cover(cover: UploadFile):
try: return await save_image(cover, "cover")
except Exception as ex:
try:
return await save_image(cover, "cover")
except Exception as ex:
print(ex)
raise HTTPException(500)