1
0
mirror of https://github.com/actix/examples synced 2025-02-02 17:39:05 +01:00

27 lines
586 B
Rust
Raw Normal View History

#[macro_use]
extern crate actix_web;
2020-04-03 16:14:30 +09:00
use actix_web::{App, HttpResponse, HttpServer, Responder};
#[get("/")]
async fn index() -> impl Responder {
println!("GET: /");
HttpResponse::Ok().body("Hello world!")
}
#[get("/again")]
async fn again() -> impl Responder {
println!("GET: /again");
HttpResponse::Ok().body("Hello world again!")
}
2020-09-12 16:49:45 +01:00
#[actix_web::main]
async fn main() -> std::io::Result<()> {
println!("Starting actix-web server");
2020-04-03 16:16:17 +09:00
HttpServer::new(|| App::new().service(index).service(again))
.bind("0.0.0.0:5000")?
.run()
.await
}