from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from src.grc import process_grc from src.ml import model, tokenizer from src.models import ProcessGrcInput import os app = FastAPI(title="GRC API") origins = [os.environ.get("FRONTEND_ORIGIN", "")] app.add_middleware( CORSMiddleware, allow_origins=origins, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) @app.get("/") def index(): return "Welcome to the GRC API" @app.post("/run") def run(input: ProcessGrcInput): return process_grc(model=model, tokenizer=tokenizer, input=input)