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

lmao
pull/1/head
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 ```shell
$ cargo run --release $ cargo run --release
# The server should listen at http://127.0.0.1:3000/ by default, # 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::path::end().and(warb::fs::file("frontend/index.html")))
.or(warb::fs::dir("frontend")); .or(warb::fs::dir("frontend"));
let host = std::env::var("HOST") let ip = std::env::var("IP")
.ok() .ok()
.and_then(|s| s.parse::<IpAddr>().ok()) .and_then(|s| s.parse::<IpAddr>().ok())
.unwrap_or_else(|| [127, 0, 0, 1].into()); .unwrap_or_else(|| [127, 0, 0, 1].into());
@ -145,6 +145,6 @@ async fn main() {
.and_then(|s| s.parse::<u16>().ok()) .and_then(|s| s.parse::<u16>().ok())
.unwrap_or(3000); .unwrap_or(3000);
println!("Listening at http://{}:{} ...", &host, &port); println!("Listening at http://{}:{} ...", &ip, &port);
warb::serve(routes).run((host, port)).await; warb::serve(routes).run((ip, port)).await;
} }