update main.py

This commit is contained in:
dmsanhrProject 2025-11-04 22:19:53 +07:00
parent 897cd5d7c3
commit 52770c1bce

13
main.py
View File

@ -17,6 +17,7 @@ from services.geometry_detector import attach_polygon_geometry_auto
from database.connection import engine
from database.models import Base
import time
from datetime import datetime, timedelta
import pathlib
from fastapi.middleware.cors import CORSMiddleware
@ -28,7 +29,7 @@ from sqlalchemy import text
UPLOAD_FOLDER.mkdir(parents=True, exist_ok=True)
apiVersion = "2.1.0"
apiVersion = "2.1.3"
app = FastAPI(
title="ETL Geo Upload Service",
version=apiVersion,
@ -203,17 +204,19 @@ def process_data(df: pd.DataFrame, ext: str):
from datetime import datetime
@app.get("/status", tags=["System"])
async def server_status():
utc_time = datetime.utcnow()
wib_time = utc_time + timedelta(hours=7)
formatted_time = wib_time.strftime("%d-%m-%Y %H:%M:%S")
response = {
"status": "success",
"message": "Server is running smoothly ✅",
"data": {
"service": "upload_automation",
"status_code": 200,
"timestamp": datetime.utcnow().isoformat() + "Z",
"timestamp": f"{formatted_time} WIB"
},
"meta": {
"version": apiVersion,
@ -225,7 +228,7 @@ async def server_status():
@app.post("/upload")
async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form("")):
async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form(""), sheet: Optional[str] = Form("")):
fname = file.filename
ext = os.path.splitext(fname)[1].lower()
contents = await file.read()
@ -242,7 +245,7 @@ async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form("
print('ext', ext)
if ext == ".csv":
df = read_csv(str(tmp_path))
df = read_csv(str(tmp_path), sheet)
elif ext == ".xlsx":
df = read_csv(str(tmp_path))
elif ext == ".pdf":