def __init__(self, dispatcher, args): PacketSource.__init__(self, dispatcher) m = re.match(r'(.*):(.*)', args) if m == None: raise PacketSourceException("bad arguments") (host, port) = m.groups() port = int(port) self.io = SocketIO(host, port) self.prot = SFProtocol(self.io, self.io)
from flask import Flask, request, render_template import os, SocketIO app = Flask(__name__) app.config["SECRET_KEY"] = os.getenv("SECRET_KEY") socketio = SocketIO(app) @app.route("/") def index(): return render_template("index.html") @socketio.on("submit vote") def vote(data): selection = data["selection"] emit("announce vote", {"selection": selection}, broadcast=True)