1
0
mirror of https://github.com/actix/actix-website synced 2025-03-15 20:53:07 +01:00

25 lines
570 B
Rust
Raw Normal View History

2020-09-12 16:21:54 +01:00
#![allow(dead_code)]
// <setup>
2020-09-12 16:21:54 +01:00
use actix_web::{web, App, HttpServer, Responder};
2019-12-29 01:15:22 +09:00
async fn index() -> impl Responder {
"Hello world!"
}
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2020-01-02 12:56:32 +06:00
async fn main() -> std::io::Result<()> {
2020-01-02 12:43:41 +06:00
HttpServer::new(|| {
App::new().service(
2020-09-12 16:21:54 +01:00
// prefixes all resources and routes attached to it...
web::scope("/app")
// ...so this handles requests for `GET /app/index.html`
.route("/index.html", web::get().to(index)),
2020-01-02 12:43:41 +06:00
)
})
2020-09-12 16:21:54 +01:00
.bind("127.0.0.1:8080")?
2020-01-02 12:43:41 +06:00
.run()
.await
}
// </setup>