1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2025-03-14 21:24:41 -05:00
chhoto-url/actix/src/main.rs

20 lines
491 B
Rust
Raw Normal View History

2023-04-02 16:53:55 -05:00
use actix_files::Files;
use actix_web::{get, web, App, HttpServer, Responder};
#[get("/hello/{name}")]
async fn greet(name: web::Path<String>) -> impl Responder {
format!("Hello {name}!")
}
#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(greet)
.service(Files::new("/", "./resources/").index_file("index.html"))
})
.bind(("127.0.0.1", 2000))?
.run()
.await
}