Answer with cooking plan and save edamam API tokens
Build, push image, and notify Watchtower / build-image (push) Successful in 3m59s
Build, push image, and notify Watchtower / notify (push) Successful in 7s

This commit is contained in:
2026-07-27 14:37:05 +02:00
parent 6a42e4a772
commit 81de985580
3 changed files with 1006 additions and 3 deletions
+13 -3
View File
@@ -5,6 +5,7 @@ from flask import Flask, request, jsonify
from pymongo import MongoClient
from APIs import generate, EdamamAPI
import sys
from microwaveCookPlanner import MicrowaveCookPlanner
sys.path.insert(0, '..')
try:
from shared import config
@@ -28,6 +29,11 @@ device_network_collection = db["device_network"]
CAMERA_IMAGE_DIR = "storage/dishCameraImages"
os.makedirs(CAMERA_IMAGE_DIR, exist_ok=True)
# ---------------------------------------------------------
# Classes
# ---------------------------------------------------------
microwave_cook_planner = MicrowaveCookPlanner()
# ---------------------------------------------------------
# Routes
# ---------------------------------------------------------
@@ -72,14 +78,18 @@ def cooking_params():
# Remove the Mongo-injected '_id' object before returning the response
data.pop("_id", None)
return jsonify({"message": "Cooking parameters saved successfully", "data": data}), 201
except Exception as e:
return jsonify({"error": f"Database error: {str(e)}"}), 500
# 3. Returns with the cooking parameters
cooking_plan = microwave_cook_planner.generate_plan(
image_path=data.get("camera_image"),
height_cm=data.get("height_cm", 4.0),
initial_temp_c=data.get("initial_temp_c", 20.0),
microwave_wattage=data.get("microwave_wattage", 900)
)
return jsonify(cooking_plan), 201
@app.route("/device-network", methods=["POST"])
def device_network():