Python Chat Tutorial with Django and React
--
Unlike other tutorials, I’m not using Python/Django for WebSocket connections. While doing so may seem cool from a tech perspective, it’s pretty sluggish and expensive — especially if you have a halfway decent number of users. Languages such as C++, Go and Elixir are much better at handling the core of chat.
In this tutorial, we will use Stream, an API for chat that takes care of WebSocket connections and other heavy lifting using Go, Raft and RocksDB.
The GitHub repo for the code below can be found at https://github.com/GetStream/python-chat-example.
Before we start thinking about the Python chat side of things let’s spin up a simple React frontend, so we have something nice and visual to look at:
Replace the code in src/App.js
with:
Next, run yarn start
to see the chat in action!
Make sure you have Python 3.7 up and running.
If that does not work, please try this snippet:
Now that you’re in your virtual env you should see python 3 when you run: