nagasurendra commited on
Commit
425a7d1
·
verified ·
1 Parent(s): 0ead5f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -64,6 +64,43 @@ def generate_coupon_code(length=10):
64
  characters = string.ascii_uppercase + string.digits # A-Z, 0-9
65
  return ''.join(random.choice(characters) for _ in range(length))
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  import re
69
  @app.route("/edit_profile", methods=["GET", "POST"])
 
64
  characters = string.ascii_uppercase + string.digits # A-Z, 0-9
65
  return ''.join(random.choice(characters) for _ in range(length))
66
 
67
+ @app.route("/generate_custom_dish", methods=["POST"])
68
+ def generate_custom_dish():
69
+ try:
70
+ data = request.form
71
+ dish_name = data.get("name")
72
+ description = data.get("description")
73
+
74
+ if not dish_name or not description:
75
+ return jsonify({"success": False, "error": "Both fields are required"}), 400
76
+
77
+ # Generate a random price for the custom dish
78
+ price = random.randint(100, 300) # Example logic for price setting
79
+
80
+ # Determine Veg/Non-Veg
81
+ veg_keywords = ["paneer", "vegetable", "mushroom", "cheese"]
82
+ non_veg_keywords = ["chicken", "mutton", "fish", "egg"]
83
+
84
+ category = "Veg" if any(word in description.lower() for word in veg_keywords) else \
85
+ "Non-Veg" if any(word in description.lower() for word in non_veg_keywords) else \
86
+ "Both"
87
+
88
+ # Store in the custom dishes list (or database, if needed)
89
+ custom_dish = {
90
+ "Name": dish_name,
91
+ "Price__c": price,
92
+ "Description__c": description,
93
+ "Veg_NonVeg__c": category,
94
+ "Section__c": "Custom Dishes",
95
+ "Total_Ordered__c": 0
96
+ }
97
+
98
+ custom_dishes.append(custom_dish) # Store in temporary list
99
+
100
+ return redirect(url_for("menu", category="Customized Dish")) # Redirect back to the menu with custom dish
101
+
102
+ except Exception as e:
103
+ return jsonify({"success": False, "error": str(e)}), 500
104
 
105
  import re
106
  @app.route("/edit_profile", methods=["GET", "POST"])