Your cart content will appear here.
import gradio as gr import pandas as pd from bcrypt import hashpw, gensalt, checkpw # File for storing user data USER_FILE = "users.xlsx" # Utility Functions from simple_salesforce import Salesforce from bcrypt import hashpw, gensalt, checkpw import datetime # Salesforce connection setup sf = Salesforce(username='diggavalli98@gmail.com', password='Sati@1020', security_token='sSSjyhInIsUohKpG8sHzty2q') # Utility Functions def save_user(name, phone, email, password): """Save user details to Salesforce.""" try: # Check if the email already exists in Salesforce query = f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{email}'" result = sf.query(query) if result['totalSize'] > 0: return False # User already exists # Hash the password hashed_password = hashpw(password.encode(), gensalt()).decode() # Insert new user record into Salesforce new_user = { "Name": name, "Email__c": email, "Password__c": hashed_password, "Phone_Number__c": phone, "Login_Status__c": "Logged Out" } sf.Customer_Login__c.create(new_user) return True except Exception as e: print(f"Error saving user: {e}") return False def check_credentials(email, password): """Check user credentials during login.""" try: # Query user by email query = f"SELECT Password__c FROM Customer_Login__c WHERE Email__c = '{email}'" result = sf.query(query) if result['totalSize'] == 1: hashed_password = result['records'][0]['Password__c'] return checkpw(password.encode(), hashed_password.encode()) return False except Exception as e: print(f"Error checking credentials: {e}") return False # Function to load the menu data def load_menu(): menu_file = "menu.xlsx" # Ensure this file exists in the same directory try: return pd.read_excel(menu_file) except Exception as e: raise ValueError(f"Error loading menu file: {e}") # Function to filter menu items based on preference def filter_menu(preference): menu_data = load_menu() if preference == "Halal/Non-Veg": filtered_data = menu_data[menu_data["Ingredients"].str.contains("Chicken|Mutton|Fish|Prawns|Goat", case=False, na=False)] elif preference == "Vegetarian": filtered_data = menu_data[~menu_data["Ingredients"].str.contains("Chicken|Mutton|Fish|Prawns|Goat", case=False, na=False)] elif preference == "Guilt-Free": filtered_data = menu_data[menu_data["Description"].str.contains(r"Fat: ([0-9]|10)g", case=False, na=False)] else: filtered_data = menu_data html_content = "" for _, item in filtered_data.iterrows(): html_content += f"""
${item['Price ($)']}
{item['Description']}