From aa4b963f320ab72de355dcbe8953a4c3e918c07e Mon Sep 17 00:00:00 2001 From: muhamad fais aizat Date: Thu, 15 May 2025 21:56:17 +0700 Subject: [PATCH] fix:remove api --- backend/api/index.py | 7 ------- backend/api/main.py | 45 ----------------------------------------- backend/api/runtime.txt | 1 - backend/vercel.json | 4 ++-- 4 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 backend/api/index.py delete mode 100644 backend/api/main.py delete mode 100644 backend/api/runtime.txt diff --git a/backend/api/index.py b/backend/api/index.py deleted file mode 100644 index 03b87797..00000000 --- a/backend/api/index.py +++ /dev/null @@ -1,7 +0,0 @@ -from fastapi import FastAPI - -app = FastAPI() - -@app.get("/") -async def health_check(): - return "berhasil" \ No newline at end of file diff --git a/backend/api/main.py b/backend/api/main.py deleted file mode 100644 index 48cd7515..00000000 --- a/backend/api/main.py +++ /dev/null @@ -1,45 +0,0 @@ -from fastapi import FastAPI -from fastapi.openapi.models import OAuthFlows as OAuthFlowsModel, SecurityScheme -from fastapi.openapi.utils import get_openapi -from fastapi.security import OAuth2PasswordBearer -from routes.index import api_router -from fastapi.middleware.cors import CORSMiddleware - -app = FastAPI() - -# Konfigurasi Swagger agar hanya meminta token (tanpa login ulang) -def custom_openapi(): - if app.openapi_schema: - return app.openapi_schema - openapi_schema = get_openapi( - title="API Prediction", - version="1.0.0", - description="API for Tomato Price Prediction", - routes=app.routes, - ) - openapi_schema["components"]["securitySchemes"] = { - "BearerAuth": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", - } - } - for path in openapi_schema["paths"].values(): - for method in path.values(): - method["security"] = [{"BearerAuth": []}] - app.openapi_schema = openapi_schema - return app.openapi_schema - -app.openapi = custom_openapi # Pakai custom OpenAPI - -app.include_router(api_router) - - -# Middleware untuk CORS (Opsional, jika API digunakan oleh frontend) -app.add_middleware( - CORSMiddleware, - allow_origins=["http://localhost:5173"], # Ganti dengan domain frontend jika perlu - allow_credentials=False, - allow_methods=["*"], - allow_headers=["*"], -) diff --git a/backend/api/runtime.txt b/backend/api/runtime.txt deleted file mode 100644 index ee92de7a..00000000 --- a/backend/api/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.10.6 \ No newline at end of file diff --git a/backend/vercel.json b/backend/vercel.json index 4efee42c..92b9d473 100644 --- a/backend/vercel.json +++ b/backend/vercel.json @@ -2,7 +2,7 @@ "version": 2, "builds": [ { - "src": "api/index.py", + "src": "index.py", "use": "@vercel/python", "config": { "runtime": "python3.10" } } @@ -10,7 +10,7 @@ "routes": [ { "src": "/(.*)", - "dest": "api/index.py" + "dest": "index.py" } ] }