mirror of
https://github.com/flibusta-apps/fb2converter_server.git
synced 2025-12-06 06:55:36 +01:00
Fix convert endpoint
This commit is contained in:
11
app/main.py
11
app/main.py
@@ -3,7 +3,7 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
from typing import AsyncIterator
|
from typing import AsyncIterator, Optional
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from fastapi import FastAPI, APIRouter, File, UploadFile, Form, HTTPException, status
|
from fastapi import FastAPI, APIRouter, File, UploadFile, Form, HTTPException, status
|
||||||
@@ -29,9 +29,14 @@ router = APIRouter(tags=["converter"])
|
|||||||
|
|
||||||
@router.post("/")
|
@router.post("/")
|
||||||
async def convert(
|
async def convert(
|
||||||
file: UploadFile = File({}),
|
file: Optional[UploadFile] = File(None),
|
||||||
format: str = Form({}),
|
format: Optional[str] = Form(None),
|
||||||
):
|
):
|
||||||
|
if file is None or format is None:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_400_BAD_REQUEST, detail="File and format required!"
|
||||||
|
)
|
||||||
|
|
||||||
format_lower = format.lower()
|
format_lower = format.lower()
|
||||||
if format_lower not in ["epub", "mobi"]:
|
if format_lower not in ["epub", "mobi"]:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
Reference in New Issue
Block a user