Update main.py

This commit is contained in:
HarshvardhanChandel 2025-03-31 07:32:19 +00:00
parent 725342187c
commit 07b55051e6

12
main.py
View file

@ -1,10 +1,12 @@
from groq_module import groq_module_fun, chat_with_groq
from helpers import jpeg_to_base64, extract_json_to_dict
from flask import Flask, request, jsonify
from flask_cors import CORS # Import CORS
import json
import os
app = Flask(__name__)
CORS(app) # Enable CORS for all routes
@app.route('/recipe-maker', methods=['POST'])
def recipe_maker():
@ -14,14 +16,12 @@ def recipe_maker():
query = data.get('query')
prompt = f''' based on the following query:
query: {query}
generate the recipe of the best 5 dishes in the following JSON format:
{{
"message": "<message response>"
"message": "<message response>",
"Recipe":{{
"dish1": {{
"name": "<dish name>",
@ -49,7 +49,6 @@ def recipe_maker():
"instructions": "<dish instructions>"
}}
}}
}}
'''
@ -57,8 +56,6 @@ def recipe_maker():
print(response)
recipe = extract_json_to_dict(response)
result = {
"recipe": recipe,
"query": query,
@ -135,8 +132,6 @@ def meal_diet_plan():
print(response)
week_diet_plan = extract_json_to_dict(response)
result = {
"meal_diet_plan": week_diet_plan,
"weight": weight,
@ -197,4 +192,3 @@ def food_scan():
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)