1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 15:39:02 +02:00

Improve home page (#305)

* improve landing page

* revert navbar
This commit is contained in:
Ibraheem Ahmed
2023-01-09 04:52:42 -05:00
committed by GitHub
parent 77ef3b62d1
commit 034a6f1890
6 changed files with 97 additions and 100 deletions

View File

@ -1,8 +1,8 @@
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use serde::Deserialize;
// <easy-form-handling>
use actix_web::web::{Either, Json, Form};
// <easy-form-handling>
#[derive(Deserialize)]
struct Register {
username: String,

View File

@ -1,24 +1,21 @@
// <request-routing>
use actix_web::{get, web, App, HttpRequest, HttpServer, Responder};
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/")]
async fn index(_req: HttpRequest) -> impl Responder {
"Hello from the index page."
async fn index() -> impl Responder {
"Hello, World!"
}
async fn hello(path: web::Path<String>) -> impl Responder {
format!("Hello {}!", &path)
#[get("/{name}")]
async fn hello(name: web::Path<String>) -> impl Responder {
format!("Hello {}!", &name)
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(index)
.route("/{name}", web::get().to(hello))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
HttpServer::new(|| App::new().service(index).service(hello))
.bind(("127.0.0.1", 8080))?
.run()
.await
}
// </request-routing>