Serving HTML, CSS, and JavaScript using Rust
In the previous chapter, we returned all our data in the form of JSON. In this section, we are going to return HTML data for the user to see. In this HTML data, we will have buttons and forms that enable the user to interact with the API endpoints that we defined in the previous chapter to create, edit, and delete to-do items. To do this, we will need to structure our own app
views module that takes the following structure:
views ├── app │ ├── items.rs │ └── mod.rs
Serving basic HTML
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 the simplest way in which we can return HTML in the items.rs
file:
use actix_web::HttpResponse; pub async fn items() -> HttpResponse { HttpResponse::Ok() ...