Displaying HTML in the browser from a server
So far, we have been processing data and returning it in JSON format. This is great, and we will be continuing to use this JSON format throughout the rest of this book. However, it is not very useful for a standard user. We need the data to be displayed when the user visits the URL. This view utilizes buttons and forms, enabling the user to interact with the API endpoints. Before this, we had to use Postman to interact with those APIs.
There are a couple of crates that enable developers to render HTML for users in Rust. In order to do this, we will need to structure our own app
views module, which takes the following structure:
└── views ├── app │ ├── items.rs │ └── mod.rs
In our items.rs
file, we will be defining the main view that displays the to-do items. However, before we do that, we should explore...