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
| import React, { useEffect } from "react"; | |
| import { io } from "socket.io-client"; | |
| import "./App.css"; | |
| const endpoint = "http://127.0.0.1:5000/"; | |
| const socket = io(endpoint, { | |
| cors: { | |
| origin: "https://example.com", | |
| methods: ["GET", "POST"], | |
| allowedHeaders: ["my-custom-header"], | |
| credentials: true, |
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') |