import os from flask import Flask, request, jsonify, render_template app = Flask(__name__) # Get Hugging Face assigned port or use local port 7860 PORT = int(os.getenv("PORT", 7860)) @app.route('/') def index(): """Serve the main page with voice recognition.""" return render_template('index.html') @app.route('/landing') def landing(): """Landing page that loads after wake-word detection.""" return render_template('landing.html') @app.route('/process_command', methods=['POST']) def process_command(): """Receives a voice command from the frontend, processes it, and returns a response.""" data = request.json user_command = data.get("command", "").lower() # Simple command responses if "menu" in user_command: response = "Here is the menu: Biryani, Kebab, Chicken Curry." elif "order" in user_command: response = "Please specify what you want to order." elif "location" in user_command: response = "Our restaurant is located at XYZ street, City." else: response = "Sorry, I didn't understand that command." return jsonify({"response": response}) if __name__ == '__main__': app.run(host="0.0.0.0", port=PORT, debug=True)