Kintone app build backend created
This commit is contained in:
BIN
backend/Temp/日報設計書.xlsx
Normal file
BIN
backend/Temp/日報設計書.xlsx
Normal file
Binary file not shown.
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]}
|
||||
@@ -1,12 +1,12 @@
|
||||
from fastapi import FastAPI, Depends
|
||||
from starlette.requests import Request
|
||||
import uvicorn
|
||||
|
||||
from app.api.api_v1.routers.users import users_router
|
||||
from app.api.api_v1.routers.auth import auth_router
|
||||
from app.api.api_v1.routers.kintone import kinton_router
|
||||
# from app.api.api_v1.routers.users import users_router
|
||||
# from app.api.api_v1.routers.auth import auth_router
|
||||
from app.core import config
|
||||
from app.db.session import SessionLocal
|
||||
from app.core.auth import get_current_active_user
|
||||
# from app.db.session import SessionLocal
|
||||
# from app.core.auth import get_current_active_user
|
||||
from app.core.celery_app import celery_app
|
||||
from app import tasks
|
||||
|
||||
@@ -16,17 +16,17 @@ app = FastAPI(
|
||||
)
|
||||
|
||||
|
||||
@app.middleware("http")
|
||||
async def db_session_middleware(request: Request, call_next):
|
||||
request.state.db = SessionLocal()
|
||||
response = await call_next(request)
|
||||
request.state.db.close()
|
||||
return response
|
||||
# @app.middleware("http")
|
||||
# async def db_session_middleware(request: Request, call_next):
|
||||
# request.state.db = SessionLocal()
|
||||
# response = await call_next(request)
|
||||
# request.state.db.close()
|
||||
# return response
|
||||
|
||||
|
||||
@app.get("/api/v1")
|
||||
async def root():
|
||||
return {"message": "Hello World"}
|
||||
return {"message": "success"}
|
||||
|
||||
|
||||
@app.get("/api/v1/task")
|
||||
@@ -37,13 +37,14 @@ async def example_task():
|
||||
|
||||
|
||||
# Routers
|
||||
app.include_router(
|
||||
users_router,
|
||||
prefix="/api/v1",
|
||||
tags=["users"],
|
||||
dependencies=[Depends(get_current_active_user)],
|
||||
)
|
||||
app.include_router(auth_router, prefix="/api", tags=["auth"])
|
||||
# app.include_router(
|
||||
# users_router,
|
||||
# prefix="/api/v1",
|
||||
# tags=["users"],
|
||||
# dependencies=[Depends(get_current_active_user)],
|
||||
# )
|
||||
# app.include_router(auth_router, prefix="/api", tags=["auth"])
|
||||
app.include_router(kinton_router,prefix="/api/v1")
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", host="0.0.0.0", reload=True, port=8888)
|
||||
|
||||
@@ -7,7 +7,7 @@ httpx==0.15.5
|
||||
ipython==7.31.1
|
||||
itsdangerous==1.1.0
|
||||
Jinja2==2.11.3
|
||||
psycopg2
|
||||
#psycopg2
|
||||
pytest==6.1.0
|
||||
requests==2.24.0
|
||||
SQLAlchemy==1.3.19
|
||||
@@ -16,4 +16,6 @@ passlib==1.7.2
|
||||
bcrypt==3.2.0
|
||||
sqlalchemy-utils==0.36.8
|
||||
python-multipart==0.0.5
|
||||
pyjwt==1.7.1
|
||||
pyjwt==1.7.1
|
||||
pandas==2.0.3
|
||||
openpyxl==3.1.2
|
||||
@@ -1,2 +1,2 @@
|
||||
KAB_BACKEND_URL="http://localhost:8000/api/"
|
||||
KAB_BACKEND_URL="http://127.0.0.1:8000/api/v1/upload"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user