Use the IP env var instead of HOST since HOST is used for the hostname

lmao
This commit is contained in:
Charlotte Som 2021-10-25 00:31:24 +01:00
parent 4b7ad17588
commit 3e00d296f8
2 changed files with 4 additions and 4 deletions

View file

@ -7,5 +7,5 @@ A Rust HTTP service that allows you to watch videos together with friends.
```shell
$ cargo run --release
# The server should listen at http://127.0.0.1:3000/ by default,
# but you can use the HOST and PORT environment variables to override this
# but you can use the IP and PORT environment variables to override this
```

View file

@ -136,7 +136,7 @@ async fn main() {
.or(warb::path::end().and(warb::fs::file("frontend/index.html")))
.or(warb::fs::dir("frontend"));
let host = std::env::var("HOST")
let ip = std::env::var("IP")
.ok()
.and_then(|s| s.parse::<IpAddr>().ok())
.unwrap_or_else(|| [127, 0, 0, 1].into());
@ -145,6 +145,6 @@ async fn main() {
.and_then(|s| s.parse::<u16>().ok())
.unwrap_or(3000);
println!("Listening at http://{}:{} ...", &host, &port);
warb::serve(routes).run((host, port)).await;
println!("Listening at http://{}:{} ...", &ip, &port);
warb::serve(routes).run((ip, port)).await;
}