fix: resolve annoyed endpoint
This commit is contained in:
parent
2d8f65e177
commit
3dee52c56a
7
main.py
7
main.py
|
|
@ -8,8 +8,7 @@ import services
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
"""Mengelola startup dan shutdown aplikasi secara efisien."""
|
print("⏳ Menghubungkan ke Database Neon...")
|
||||||
print("⏳ Menghubungkan ke Database...")
|
|
||||||
await prisma.connect()
|
await prisma.connect()
|
||||||
|
|
||||||
print("🤖 Memuat Asset Machine Learning (XGBoost)...")
|
print("🤖 Memuat Asset Machine Learning (XGBoost)...")
|
||||||
|
|
@ -22,13 +21,13 @@ async def lifespan(app: FastAPI):
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Tokopedia Laptop Recommendation API",
|
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
|
lifespan=lifespan
|
||||||
)
|
)
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=["http://localhost:3000"],
|
allow_origins=["*"],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
allow_methods=["*"],
|
allow_methods=["*"],
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
pandas
|
|
||||||
numpy
|
|
||||||
scikit-learn
|
|
||||||
xgboost
|
|
||||||
selenium
|
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
nltk
|
fastapi
|
||||||
sastrawi
|
imbalanced_learn
|
||||||
matplotlib
|
|
||||||
seaborn
|
|
||||||
wordcloud
|
|
||||||
imblearn
|
|
||||||
joblib
|
joblib
|
||||||
|
matplotlib
|
||||||
|
nltk
|
||||||
|
numpy
|
||||||
|
pandas
|
||||||
|
pydantic
|
||||||
|
Sastrawi
|
||||||
|
scikit_learn
|
||||||
|
seaborn
|
||||||
|
selenium
|
||||||
|
undetected_chromedriver
|
||||||
|
wordcloud
|
||||||
|
xgboost
|
||||||
|
uvicorn
|
||||||
|
prisma
|
||||||
|
playwright
|
||||||
|
|
@ -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)
|
||||||
Loading…
Reference in New Issue