Instead, let's make the server send back any message it receives - a behavior also known as an "echo" endpoint.Īdd the following between the app object declaration and the app.run() block in app.py: If you're interested in learning more about WebSockets in Python, I strongly recommend this talk: A beginner's guide to WebSockets.Īlright, so we won't plug the chatbot in yet. It's good old sockets reinvented for the web.ĭue to their bidirectional nature, they're very suitable for the kind of application we're building here - some sort of conversation between a client and a server (i.e. If you're not familiar with WebSocket, don't worry - here's a 10-word summary: it allows a server and a client to exchange messages in a bidirectional way. We're now ready to get to the meat of it! The first thing we'll build is the WebSocket endpoint. If you go to and get a 404 Not Found response, you're all good! Enter Ctrl+C in your terminal to stop the server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |