Spaces:
Runtime error
Runtime error
import uvicorn | |
from fastapi import FastAPI | |
from fastapi.middleware.cors import CORSMiddleware | |
from src.hf import generate_response | |
app = FastAPI() | |
# for CORS | |
origins = ['http://localhost:3000', 'http://localhost:5173', 'http://localhost:5174'] | |
# middleware | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins = origins, | |
allow_credentials = True, | |
allow_methods = ['*'], | |
allow_headers = ['*'] | |
) | |
async def root(): | |
return {"message": "Hello World"} | |
async def root(): | |
return {"book_name": "Hikayat Naga Terbang"} | |
async def classify_text(question:str): | |
answer = generate_response(question) | |
topic_label, score = answer | |
return {"label": topic_label} | |
if __name__ == '__main__': | |
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True) |