| from flask import Flask, request, redirect, url_for |
|
|
| app = Flask(__name__) |
|
|
| |
| messages = [] |
|
|
| |
| @app.route('/', methods=['GET', 'POST']) |
| def index(): |
| global messages |
| html = "<html><body>" |
| html += "<h2>Simple Chat Share</h2>" |
|
|
| if request.method == 'POST': |
| text = request.form.get('text') |
| if text: |
| messages.append(text) |
| return redirect(url_for('index')) |
|
|
| |
| html += "<form method='POST'>" |
| html += "Message:<br>" |
| html += "<input type='text' name='text' style='width:300px'>" |
| html += "<input type='submit' value='Send'>" |
| html += "</form><hr>" |
|
|
| |
| html += "<h3>Messages:</h3>" |
| for i, msg in enumerate(messages[::-1], 1): |
| |
| html += f"<p>{i}: <input type='text' value='{msg}' readonly style='width:300px'> <button onclick='this.previousElementSibling.select();document.execCommand(\"copy\");'>Copy</button></p>" |
|
|
| html += "</body></html>" |
| return html |
|
|
| |
| if __name__ == '__main__': |
| app.run(host='0.0.0.0', port=7860) |