This is my relevant Rust code:
async fn index() -> Result<HttpResponse> {
Ok(HttpResponse::build(StatusCode::OK)
.content_type("text/html;charset=utf-8")
.body(include_str!("../html/index.html"))
)
}
index.html:
<link rel="stylesheet" type="text/css" href="css/general.css">
File structure:
├── Cargo.lock
├── Cargo.toml
├── html
│ ├── css
│ │ └── general.css
│ ├── index.html
│ ├── login.html
│ └── register.html
└── src
└── main.rs
When I run the code and go to 127.0.0.1:8080
the HTML gets loaded as expected but the CSS doesn't. I tried every path to the css file possible (relative from cargo run
location etc) but none worked.
How to get the CSS to work?