Kintone app build backend created
This commit is contained in:
23
backend/app/api/api_v1/routers/kintone.py
Normal file
23
backend/app/api/api_v1/routers/kintone.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from fastapi import APIRouter, UploadFile,HTTPException,File
|
||||
from io import BytesIO
|
||||
import typing as t
|
||||
import pandas as pd
|
||||
|
||||
|
||||
kinton_router = r = APIRouter()
|
||||
|
||||
|
||||
@r.post("/upload",)
|
||||
async def upload(files:t.List[UploadFile] = File(...)):
|
||||
dataframes = []
|
||||
for file in files:
|
||||
if file.filename.endswith('.xlsx'):
|
||||
try:
|
||||
content = await file.read()
|
||||
df = pd.read_excel(BytesIO(content))
|
||||
dataframes.append(df)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=400, detail=f"Error occurred while parsing file {file.filename}: {str(e)}")
|
||||
else:
|
||||
raise HTTPException(status_code=400, detail=f"File {file.filename} is not an Excel file")
|
||||
return {"files": [file.filename for file in files]}
|
||||
Reference in New Issue
Block a user