Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from utils import init_model, inference | |
| app = FastAPI() | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins="*", # Allow only specified origins | |
| allow_credentials=True, # Allow credentials (e.g., cookies) | |
| allow_methods=["*"], # Allow all HTTP methods (GET, POST, etc.) | |
| allow_headers=["*"], # Allow all headers | |
| ) | |
| # initializing the model | |
| model = init_model("BooksDataSet.csv", "model.pkl") | |
| def model_inference( | |
| tokens : str | |
| ): | |
| return inference(model, tokens) | |
| def greet_json(): | |
| return {"Hello": "World!"} | |