svm-model / app.py
amitansu1024's picture
fixed import bug
161aac0
Raw
History Blame Contribute Delete
655 Bytes
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")
@app.post("/infer")
def model_inference(
tokens : str
):
return inference(model, tokens)
@app.get("/")
def greet_json():
return {"Hello": "World!"}