2020-09-12 16:21:54 +01:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2019-06-19 00:20:50 -04:00
|
|
|
// <setup>
|
2020-09-12 16:21:54 +01:00
|
|
|
use actix_web::{web, App, HttpServer, Responder};
|
2019-06-19 00:20:50 -04:00
|
|
|
|
2019-12-29 01:15:22 +09:00
|
|
|
async fn index() -> impl Responder {
|
2019-06-19 00:20:50 -04:00
|
|
|
"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
|
2019-06-19 00:20:50 -04:00
|
|
|
}
|
|
|
|
// </setup>
|