Last active
October 14, 2021 13:34
-
-
Save walpolsh/e4db1cb0d4f51c3852ef3720a29cc16a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from flask import Flask, request, jsonify | |
| from flask_socketio import SocketIO, emit | |
| from flask_cors import CORS | |
| app = Flask(__name__) | |
| socketio = SocketIO(app, logger=True, engineio_logger=True, cors_allowed_origins='http://localhost:3001') | |
| CORS(app) | |
| @socketio.on('connect') | |
| def on_connect(): | |
| print('connected dude') | |
| payload = dict(data='Connected') | |
| print(payload) | |
| emit('log', payload, broadcast=True) | |
| @socketio.on('message') | |
| def handle_message(data): | |
| print('received message: ' + data) | |
| if __name__ == '__main__': | |
| socketio.run(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment