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

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>")
}