RohanHBTU/Hinglish_FastAPI
0
1from fastapi import FastAPI2from fastapi.middleware.cors import CORSMiddleware3 4from inference import outcome5import warnings6warnings.filterwarnings("ignore")7 8app=FastAPI()9 10app.add_middleware(11 CORSMiddleware,12 allow_origins=["*"],13 allow_credentials=True,14 allow_methods=["*"],15 allow_headers=["*"],16)17 18#since CORS has been enabled, this api can be used to fetch data using jquery (https://api.jquery.com/jQuery.get/)19 20@app.get('/')21def index():22 return {"message":"Welcome to Hinglish Translator"}23 24@app.post('/predict')25def predict(input: str):26 return {"result":outcome(input)}27 