Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

actix web hello world

use actix_web::{get, post, web, App, HttpRequest, HttpResponse, HttpServer, Responder};

#[get("/")]
async fn hello() -> impl Responder {
    HttpResponse::Ok().body("Hello World")
}

// remains post, patch, put, delete etc requests


#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| App::new().service(hello))
        .bind(("127.0.0.1", 8080))?
        .run()
        .await
}
 
PREVIOUS NEXT
Tagged: #actix #web #world
ADD COMMENT
Topic
Name
1+4 =