Ntex, index route

This commit is contained in:
DarkCat09 2024-02-22 12:22:40 +04:00
parent 454d10a071
commit 4b6b3f7da4
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3
4 changed files with 1219 additions and 2 deletions

1200
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ntex = { version = "1.1.0", features = ["tokio"] }

View file

@ -1,3 +1,11 @@
fn main() {
println!("Hello, world!");
use ntex::web::{self, App};
mod pages;
#[ntex::main]
async fn main() -> std::io::Result<()> {
web::server(move || App::new().service(pages::index))
.bind("127.0.0.1:3002")?
.run()
.await
}

8
src/pages.rs Normal file
View file

@ -0,0 +1,8 @@
use ntex::web::{self, HttpResponse};
#[web::get("/")]
pub async fn index() -> HttpResponse {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body("<h1>dc09's bin</h1>")
}