File size: 655 Bytes
c9fd631
161aac0
d8e1c3b
c9fd631
 
 
d8e1c3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9fd631
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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!"}