Finished program
This commit is contained in:
25
src/main.rs
Normal file
25
src/main.rs
Normal 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])
|
||||
}
|
||||
Reference in New Issue
Block a user