from flask import Flask, request, render_template from api import API APP = Flask(__name__) api = API() messages = [] @APP.route('/', methods=['GET', 'POST']) def index(): global messages if request.method == 'POST': option = request.form['option'] user_message = request.form['user_message'] if option == "voice": messages.append(f"User: {user_message}") elif option == "chat": messages.append(f"User: {user_message}") ai_response = "AI: " + api.send_message(user_message, 1) messages.append(ai_response) return render_template('index.html', messages=messages) if __name__ == '__main__': APP.run(debug=True)