fn http_server() {
std::thread::spawn(|| {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(actix());
});
}
#[actix_web::get("/*")]
async fn hello() -> String {
format!("OKK")
}
async fn actix() {
let run = actix_web::HttpServer::new(|| {
actix_web::App::new().service(hello)
}).bind("0.0.0.0:8080").unwrap().run().await;
if let Err(e) = run {
println!("HTTP服务启动失败:{}", e);
}
}