Files

1 line
6.2 KiB
JSON

{"repo": "ajmal-6/web-1", "files": {"app.py": {"60f154e780e39864409a0acf543254ca3b183747": {"t": 1785745978.8090134, "n": 1902, "h": "ea8a0d0f7dc3902a", "c": "from flask import Flask, request, jsonify, render_template\nimport requests # For calling external APIs\nimport os\n\napp = Flask(__name__, static_folder='static', template_folder='templates')\n\n# --- DeepSeek API Integration ---\nDEEPSEEK_API_KEY = os.getenv(\"DEEPSEEK_API_KEY\") # Set this in your environment\n\ndef get_recipe_from_ai(ingredients):\n \"\"\"Fetch recipes from DeepSeek API or use a fallback.\"\"\"\n if DEEPSEEK_API_KEY:\n try:\n headers = {\"Authorization\": f\"Bearer {DEEPSEEK_API_KEY}\"}\n prompt = f\"Suggest 2 detailed recipes using these ingredients: {ingredients}. Include preparation steps.\"\n \n response = requests.post(\n \"https://api.deepseek.com/v1/chat/completions\", # Check actual API endpoint\n headers=headers,\n json={\"model\": \"deepseek-chat\", \"messages\": [{\"role\": \"user\", \"content\": prompt}]}\n )\n \n if response.status_code == 200:\n return response.json()[\"choices\"][0][\"message\"][\"content\"]\n \n except Exception as e:\n print(\"DeepSeek API Error:\", e)\n \n # Fallback if API fails\n return f\"\"\"Here's a sample recipe using {ingredients}:\n \n1. **Stir-Fry**:\n - Sauté {ingredients.split(',')[0]} with garlic and oil.\n - Add remaining ingredients and stir-fry for 5 mins.\n - Serve hot!\n\n2. **Salad**:\n - Chop {ingredients} finely.\n - Toss with olive oil, lemon juice, and salt.\n - Refrigerate for 30 mins before serving.\"\"\"\n\n# --- Routes ---\n@app.route(\"/\")\ndef home():\n return render_template(\"index.html\")\n\n@app.route(\"/api/get_recipe\", methods=[\"POST\"])\ndef get_recipe():\n data = request.json\n ingredients = data.get(\"ingredients\", \"\")\n \n recipe = get_recipe_from_ai(ingredients)\n return jsonify({\"recipe\": recipe})\n\nif __name__ == \"__main__\":\n app.run(debug=True)"}, "979b83a11f40e139ea037cad5d6f0aa779e7a175": {"t": 1785758461.6049652, "n": 1902, "h": "ea8a0d0f7dc3902a", "c": "from flask import Flask, request, jsonify, render_template\nimport requests # For calling external APIs\nimport os\n\napp = Flask(__name__, static_folder='static', template_folder='templates')\n\n# --- DeepSeek API Integration ---\nDEEPSEEK_API_KEY = os.getenv(\"DEEPSEEK_API_KEY\") # Set this in your environment\n\ndef get_recipe_from_ai(ingredients):\n \"\"\"Fetch recipes from DeepSeek API or use a fallback.\"\"\"\n if DEEPSEEK_API_KEY:\n try:\n headers = {\"Authorization\": f\"Bearer {DEEPSEEK_API_KEY}\"}\n prompt = f\"Suggest 2 detailed recipes using these ingredients: {ingredients}. Include preparation steps.\"\n \n response = requests.post(\n \"https://api.deepseek.com/v1/chat/completions\", # Check actual API endpoint\n headers=headers,\n json={\"model\": \"deepseek-chat\", \"messages\": [{\"role\": \"user\", \"content\": prompt}]}\n )\n \n if response.status_code == 200:\n return response.json()[\"choices\"][0][\"message\"][\"content\"]\n \n except Exception as e:\n print(\"DeepSeek API Error:\", e)\n \n # Fallback if API fails\n return f\"\"\"Here's a sample recipe using {ingredients}:\n \n1. **Stir-Fry**:\n - Sauté {ingredients.split(',')[0]} with garlic and oil.\n - Add remaining ingredients and stir-fry for 5 mins.\n - Serve hot!\n\n2. **Salad**:\n - Chop {ingredients} finely.\n - Toss with olive oil, lemon juice, and salt.\n - Refrigerate for 30 mins before serving.\"\"\"\n\n# --- Routes ---\n@app.route(\"/\")\ndef home():\n return render_template(\"index.html\")\n\n@app.route(\"/api/get_recipe\", methods=[\"POST\"])\ndef get_recipe():\n data = request.json\n ingredients = data.get(\"ingredients\", \"\")\n \n recipe = get_recipe_from_ai(ingredients)\n return jsonify({\"recipe\": recipe})\n\nif __name__ == \"__main__\":\n app.run(debug=True)"}, "e109cb87dda350842425b39f8943624c37ab210d": {"t": 1785758463.8788345, "n": 1849, "h": "ffb0f2ce789a8617", "c": "from flask import Flask, request, jsonify, render_template\nimport requests # For calling external APIs\nimport os\n\napp = Flask(__name__)\n\n# --- DeepSeek API Integration ---\nDEEPSEEK_API_KEY = os.getenv(\"DEEPSEEK_API_KEY\") # Set this in your environment\n\ndef get_recipe_from_ai(ingredients):\n \"\"\"Fetch recipes from DeepSeek API or use a fallback.\"\"\"\n if DEEPSEEK_API_KEY:\n try:\n headers = {\"Authorization\": f\"Bearer {DEEPSEEK_API_KEY}\"}\n prompt = f\"Suggest 2 detailed recipes using these ingredients: {ingredients}. Include preparation steps.\"\n \n response = requests.post(\n \"https://api.deepseek.com/v1/chat/completions\", # Check actual API endpoint\n headers=headers,\n json={\"model\": \"deepseek-chat\", \"messages\": [{\"role\": \"user\", \"content\": prompt}]}\n )\n \n if response.status_code == 200:\n return response.json()[\"choices\"][0][\"message\"][\"content\"]\n \n except Exception as e:\n print(\"DeepSeek API Error:\", e)\n \n # Fallback if API fails\n return f\"\"\"Here's a sample recipe using {ingredients}:\n \n1. **Stir-Fry**:\n - Sauté {ingredients.split(',')[0]} with garlic and oil.\n - Add remaining ingredients and stir-fry for 5 mins.\n - Serve hot!\n\n2. **Salad**:\n - Chop {ingredients} finely.\n - Toss with olive oil, lemon juice, and salt.\n - Refrigerate for 30 mins before serving.\"\"\"\n\n# --- Routes ---\n@app.route(\"/\")\ndef home():\n return render_template(\"index.html\")\n\n@app.route(\"/api/get_recipe\", methods=[\"POST\"])\ndef get_recipe():\n data = request.json\n ingredients = data.get(\"ingredients\", \"\")\n \n recipe = get_recipe_from_ai(ingredients)\n return jsonify({\"recipe\": recipe})\n\nif __name__ == \"__main__\":\n app.run(debug=True)"}}}}