Rustでのlocalhostアクセスエラー
解決したいこと
RustでWEBフレームワークを作成する勉強をしています。
iMac(M1)を使用しています。
ブラウザでlocalhostにアクセスするプログラムを作成し実行しようとしたところエラーが発生しました。
解決方法を教えていただけたら嬉しいです。
宜しくお願いします。
発生している問題・エラー
%cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.19s
Running `target/debug/todo`
thread 'main' panicked at 'System is not running', /Users/hiro_moss/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-rt-1.1.1/src/system.rs:78:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
該当するソースコード
use actix_web::{get, App, HttpResponse, HttpServer};
#[get("/")]
async fn index() -> Result<HttpResponse, actix_web::Error> {
let response_body = "Hello world!";
Ok(HttpResponse::Ok().body(response_body))
}
#[actix_rt::main]
async fn main() -> Result<(), actix_web::Error> {
HttpServer::new(move || App::new().service(index))
.bind("0.0.0.0:8080")?
.run()
.await?;
Ok(())
}
自分で試したこと
試しにファイアウォールをオフにしてみましたが、結果は変わりませんでした。
0 likes