Building WebSockets with asynchronous transactions
WebSocket is a well-known bi-directional communication between a server and browser-based clients. Many popular frameworks such as Spring, JSF, Jakarta EE, Django, FastAPI, Angular, and React support this technology, and Flask is one of them. However, this chapter will focus on implementing WebSocket and its client applications using the asynchronous paradigm.
Creating the client-side application
Our WebSocket implementation with the client-side application is in the ch05-web
project. Calling /ch05/votecount/add
from the vote_count.py
view module will give us the following HTML form in Figure 5.2, which handles the data entry for the final vote tally per precinct or election district:
Figure 5.2 – Client-side application for adding final vote counts
Our WebSocket captures election data from officers and then updates DB records in real time. It retrieves a string message from the server as...