Spaces:
Runtime error
Runtime error
File size: 982 Bytes
7bd9199 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from fastapi import APIRouter, HTTPException, Query, Path, UploadFile, File
from pydantic import BaseModel
from typing import List, Optional
from uuid import UUID
from datetime import datetime
from src.config import logger
from src.services import FileService
import io
class Response(BaseModel):
status: str
data: str
class FileController:
def __init__(self):
self.service = FileService
self.router = APIRouter()
self.router.add_api_route(
"/files",
self.get_files_extrcated_text,
methods=["POST"],
tags=["Files"],
)
async def get_files_extrcated_text(self, file: UploadFile = File(...)):
try:
async with self.service() as service:
result = await service.extract_file(file=file)
return result
except Exception as e:
logger.error(e)
raise HTTPException(status_code=500, detail="Error processing file") |