EmTpro01's picture
Upload 4 files
4312b6d verified
raw
history blame
1.02 kB
# app/main.py
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.models.recipe import RecipeRequest, RecipeResponse
from app.services.recipe_generator import RecipeGenerator
app = FastAPI(title="Recipe Generation API")
# Configure CORS for Vercel frontend
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Update this with your Vercel app URL in production
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Initialize recipe generator service
recipe_generator = RecipeGenerator()
@app.get("/")
async def root():
return {"message": "Recipe Generation API is running"}
@app.post("/generate-recipe", response_model=RecipeResponse)
async def generate_recipe(request: RecipeRequest):
recipe = await recipe_generator.generate(request.ingredients)
return RecipeResponse(
title=recipe["title"],
ingredients=recipe["ingredients"],
instructions=recipe["instructions"]
)