mirror of
https://github.com/Andre-Bzk/Rezept0r.git
synced 2026-11-15 15:43:04 +01:00
Prototyp
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""POST /api/import – import recipe to Tandoor."""
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from app.models import ExtractResponse
|
||||
from app.services.tandoor_service import import_to_tandoor
|
||||
from app.services.history_service import mark_imported
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/import")
|
||||
async def import_recipe(data: ExtractResponse):
|
||||
try:
|
||||
result = await import_to_tandoor(data.recipe)
|
||||
tandoor_recipe_id = result.get("id")
|
||||
if data.history_id:
|
||||
mark_imported(data.history_id, tandoor_recipe_id)
|
||||
return {"status": "ok", "recipe_id": tandoor_recipe_id}
|
||||
except RuntimeError as e:
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Import fehlgeschlagen: {e}")
|
||||
Reference in New Issue
Block a user