mirror of
https://github.com/StepanovPlaton/torrent_backend.git
synced 2026-04-03 20:30:38 +04:00
Add file upload
This commit is contained in:
20
routes/files.py
Normal file
20
routes/files.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, UploadFile
|
||||
|
||||
from database import *
|
||||
from file_handler import *
|
||||
|
||||
router = APIRouter(prefix="/files", tags=["Files"])
|
||||
|
||||
@router.post("/torrent", response_model=str)
|
||||
async def upload_torrent(torrent: UploadFile):
|
||||
try: return await save_torrent_file(torrent)
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
raise HTTPException(500)
|
||||
|
||||
@router.post("/cover", response_model=str)
|
||||
async def upload_cover(cover: UploadFile):
|
||||
try: return await save_image(cover, "cover")
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
raise HTTPException(500)
|
||||
Reference in New Issue
Block a user