Chat-ipad / app.py
CORVO-AI's picture
Update app.py
a7b1d1b verified
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><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'))
# Chat input form
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>"
# Display messages with copy button
html += "<h3>Messages:</h3>"
for i, msg in enumerate(messages[::-1], 1): # newest first
# Using simple input box to allow easy copy/paste
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
# --- Run the app ---
if __name__ == '__main__':
app.run(host='0.0.0.0', port=7860)