use rocket::response::content; use rocket::{State, get, post, request::Form, routes}; use rocket::response::NamedFile; use rocket_contrib::json::Json; // use std::sync::Arc; use crate::webserver::model::*; use sysinfo::{ ProcessExt, SystemExt, System, get_current_pid }; pub async fn start_rocket() -> WispResult { // ctx: WispData rocket::ignite() .mount("/", routes![ icon, index ]).launch(); Ok(()) } #[get("/favicon.ico")] pub fn icon() -> Option { NamedFile::open("static/favicon.ico").ok() } #[get("/")] pub fn index() -> content::Json<&'static str> { content::Json("{\"message\": \"online\"}") } #[get("/")] pub fn memory_usage() -> Json<&'static str> { let sys = System::new(); let mut response; if let Some(process) = sys.get_process(get_current_pid()) { // response = format!("{{\"message\": \"{}\"}}", process.memory()/1000); } else { response = "{\"message\": \"null\"}".to_string(); } Json(Json(&response)) }