fix: resolve annoyed endpoint

This commit is contained in:
Mahen 2026-04-04 12:46:52 +07:00
parent 2d8f65e177
commit 3dee52c56a
3 changed files with 31 additions and 14 deletions

View File

@ -8,8 +8,7 @@ import services
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Mengelola startup dan shutdown aplikasi secara efisien."""
print("⏳ Menghubungkan ke Database...")
print("⏳ Menghubungkan ke Database Neon...")
await prisma.connect()
print("🤖 Memuat Asset Machine Learning (XGBoost)...")
@ -22,13 +21,13 @@ async def lifespan(app: FastAPI):
app = FastAPI(
title="Tokopedia Laptop Recommendation API",
description="Backend untuk analisis sentimen ulasan laptop menggunakan XGBoost",
description="Backend analisis sentimen ulasan laptop menggunakan XGBoost - Syafrizal Wd Mahendra",
lifespan=lifespan
)
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:3000"],
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],

View File

@ -1,13 +1,19 @@
pandas
numpy
scikit-learn
xgboost
selenium
beautifulsoup4
nltk
sastrawi
matplotlib
seaborn
wordcloud
imblearn
fastapi
imbalanced_learn
joblib
matplotlib
nltk
numpy
pandas
pydantic
Sastrawi
scikit_learn
seaborn
selenium
undetected_chromedriver
wordcloud
xgboost
uvicorn
prisma
playwright

12
run.py Normal file
View File

@ -0,0 +1,12 @@
import asyncio
import sys
import uvicorn
if __name__ == "__main__":
# Paksa penggunaan SelectorEventLoop di level paling dasar OS Windows
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
print("✅ Mesin Selector Loop Aktif (Anti-NotImplementedError)")
# Jalankan uvicorn dari sini, bukan dari terminal langsung
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)