mirror of
https://github.com/actix/actix-website
synced 2025-03-15 12:43:07 +01:00
25 lines
573 B
Rust
25 lines
573 B
Rust
#![allow(dead_code)]
|
|
|
|
// <setup>
|
|
use actix_web::{web, App, HttpServer, Responder};
|
|
|
|
async fn index() -> impl Responder {
|
|
"Hello world!"
|
|
}
|
|
|
|
#[actix_web::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
HttpServer::new(|| {
|
|
App::new().service(
|
|
// 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)),
|
|
)
|
|
})
|
|
.bind(("127.0.0.1", 8080))?
|
|
.run()
|
|
.await
|
|
}
|
|
// </setup>
|