Ntex, index route
This commit is contained in:
parent
454d10a071
commit
4b6b3f7da4
4 changed files with 1219 additions and 2 deletions
1200
Cargo.lock
generated
Normal file
1200
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -6,3 +6,4 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ntex = { version = "1.1.0", features = ["tokio"] }
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,3 +1,11 @@
|
||||||
fn main() {
|
use ntex::web::{self, App};
|
||||||
println!("Hello, world!");
|
|
||||||
|
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
8
src/pages.rs
Normal 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>")
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue