Created
October 14, 2021 13:33
-
-
Save walpolsh/b5cc7552cfbd407a66d4be9efd2ddd24 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
| 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, | |
| }, | |
| }); | |
| function App() { | |
| useEffect(() => { | |
| socket.on("connect", (data) => { | |
| console.log(data); // true | |
| socket.emit("my event", { data: "I'm connected!" }); | |
| }); | |
| }, []); | |
| return <div className="App">flask server test</div>; | |
| } | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment