Browse Source

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

lmao
pull/1/head
Charlotte Som 10 months ago
parent
commit
3e00d296f8
  1. 2
      README.md
  2. 6
      src/main.rs

2
README.md

@ -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
```

6
src/main.rs

@ -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;
}

Loading…
Cancel
Save