Spaces:
Runtime error
Runtime error
| import os | |
| import uvicorn | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from src.hf import get_dir | |
| 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(): | |
| current_dir = os.getcwd() | |
| return {"message": "Hello World", "dir": current_dir} | |
| async def root(): | |
| return {"book_name": "Hikayat Naga Terbang"} | |
| # @app.post('/classify') | |
| # async def classify_text(question:str): | |
| # answer = generate_response(question) | |
| # topic_label, score = answer | |
| # | |
| # return {"label": topic_label} | |
| def get_hf_dir(): | |
| return { | |
| "hf_dir": get_dir() | |
| } | |
| if __name__ == '__main__': | |
| uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True) |