from flask import Flask, request, redirect, url_for app = Flask(__name__) # In-memory storage for chat messages messages = [] # --- Home page --- @app.route('/', methods=['GET', 'POST']) def index(): global messages html = "" html += "

Simple Chat Share

" if request.method == 'POST': text = request.form.get('text') if text: messages.append(text) return redirect(url_for('index')) # Chat input form html += "
" html += "Message:
" html += "" html += "" html += "

" # Display messages with copy button html += "

Messages:

" for i, msg in enumerate(messages[::-1], 1): # newest first # Using simple input box to allow easy copy/paste html += f"

{i}:

" html += "" return html # --- Run the app --- if __name__ == '__main__': app.run(host='0.0.0.0', port=7860)