34 lines
854 B
Python
34 lines
854 B
Python
|
|
|
||
|
|
from fastapi import APIRouter, File, Form, UploadFile
|
||
|
|
from pydantic import BaseModel
|
||
|
|
from typing import List, Optional
|
||
|
|
from services.upload_file.upload import handle_upload_file, handle_process_pdf, handle_to_postgis
|
||
|
|
|
||
|
|
router = APIRouter()
|
||
|
|
|
||
|
|
|
||
|
|
@router.post("/file")
|
||
|
|
async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form(""), sheet: Optional[str] = Form("")):
|
||
|
|
return await handle_upload_file(file, page, sheet)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class PdfRequest(BaseModel):
|
||
|
|
title: str
|
||
|
|
columns: List[str]
|
||
|
|
rows: List[List]
|
||
|
|
|
||
|
|
@router.post("/process-pdf")
|
||
|
|
async def upload_file(payload: PdfRequest):
|
||
|
|
return await handle_process_pdf(payload)
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
class UploadRequest(BaseModel):
|
||
|
|
title: str
|
||
|
|
rows: List[dict]
|
||
|
|
columns: List[str]
|
||
|
|
|
||
|
|
@router.post("/to-postgis")
|
||
|
|
def upload_to_postgis(payload: UploadRequest):
|
||
|
|
return handle_to_postgis(payload)
|