Finished program

This commit is contained in:
Joshua Higgins
2025-04-08 19:40:11 -04:00
parent aa69268fe2
commit e8954d40bc
6 changed files with 65 additions and 0 deletions

25
src/main.rs Normal file
View File

@@ -0,0 +1,25 @@
use rocket::http::Status;
use rocket::*;
use std::process::Command;
#[get("/")]
fn index() -> Status {
let result = Command::new("ping")
.args(["8.8.8.8", "-c", "1", "-W", "1"])
.status();
match result {
Ok(stream) => {
match stream.success() {
true => Status::Ok,
false => Status::InternalServerError,
}
}
Err(_) => Status::InternalServerError,
}
}
#[launch]
fn rocket() -> _ {
build().mount("/", routes![index])
}