import os from flask import Flask, render_template from flask_socketio import SocketIO, send from pyngrok import ngrok # Initialize Flask app and SocketIO app = Flask(__name__) app.config['SECRET_KEY'] = 'secret!' socketio = SocketIO(app) # HTML template for the chat chat_html = ''' Spider-Chat
''' @app.route('/') def chat(): return chat_html @socketio.on('message') def handleMessage(msg): print('Message: ' + msg) send(msg, broadcast=True) # Start ngrok to expose the app url = ngrok.connect(5000) print(' * Tunnel URL:', url) if __name__ == '__main__': socketio.run(app, port=5000, allow_unsafe_werkzeug=True)