File size: 629 Bytes
4f29464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Flask, render_template, request, jsonify

app = Flask(__name__)

# Store chat history
chat_history = []

@app.route('/')
def index():
    return render_template('index.html', chat_history=chat_history)

@app.route('/send_message', methods=['POST'])
def send_message():
    user_message = request.form['message']
    # Here you can process the user message and generate a response
    bot_response = f"Echo: {user_message}"
    chat_history.append({'user': user_message, 'bot': bot_response})
    return jsonify(chat_history=chat_history)

if __name__ == '__main__':
    app.run(debug=True)