{"library":"python-socketio","code":"import socketio\nimport eventlet\n\nsio = socketio.Server(cors_allowed_origins=\"*\")\napp = socketio.WSGIApp(sio, static_files={\n    '/': {'content_type': 'text/html', 'filename': 'index.html'}\n})\n\n@sio.event\ndef connect(sid, environ):\n    print('connect ', sid)\n\n@sio.event\ndef my_message(sid, data):\n    print('message ', data)\n    sio.emit('my response', {'data': data}, room=sid)\n\n@sio.event\ndef disconnect(sid):\n    print('disconnect ', sid)\n\nif __name__ == '__main__':\n    # index.html for testing\n    with open('index.html', 'w') as f:\n        f.write('''\n            <!DOCTYPE html>\n            <html>\n            <head>\n                <title>Socket.IO Test</title>\n                <script src=\"https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js\"></script>\n            </head>\n            <body>\n                <h1>Socket.IO Test</h1>\n                <script type=\"text/javascript\">\n                    var socket = io();\n                    socket.on('connect', function() {\n                        console.log('Connected!');\n                        socket.emit('my_message', 'Hello from browser!');\n                    });\n                    socket.on('my response', function(data) {\n                        console.log('Received:', data);\n                    });\n                    socket.on('disconnect', function() {\n                        console.log('Disconnected!');\n                    });\n                </script>\n            </body>\n            </html>\n        ''')\n    print(\"Starting server on http://localhost:5000\")\n    eventlet.wsgi.server(eventlet.listen(('', 5000)), app)\n","lang":"python","description":"This quickstart demonstrates a basic Socket.IO server using `eventlet` and a simple HTML client. The server defines handlers for `connect`, `my_message`, and `disconnect` events. The client connects, sends a message, and receives a response. An `index.html` file is created on the fly for easy testing. Remember to `pip install eventlet` for this example to run.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}