jinhai-2012 commited on
Commit
6ad8d57
·
1 Parent(s): 90444f3

Introduce actix web template

Browse files

Signed-off-by: jinhai <[email protected]>

Files changed (2) hide show
  1. Cargo.toml +6 -2
  2. src/main.rs +18 -2
Cargo.toml CHANGED
@@ -6,5 +6,9 @@ edition = "2021"
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
 
8
  [dependencies]
9
- actix = "0.13.1"
10
- postgres = "0.19.7"
 
 
 
 
 
6
  # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
 
8
  [dependencies]
9
+ actix-web = "4.3.1"
10
+ actix-rt = "2.8.0"
11
+ postgres = "0.19.7"
12
+
13
+ [[bin]]
14
+ name = "doc_gpt"
src/main.rs CHANGED
@@ -1,3 +1,19 @@
1
- fn main() {
2
- println!("Hello, world!");
 
 
 
3
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ use actix_web::{get, web, App, HttpServer, Responder};
2
+
3
+ #[get("/")]
4
+ async fn index() -> impl Responder {
5
+ "Hello, World!"
6
  }
7
+
8
+ #[get("/{name}")]
9
+ async fn hello(name: web::Path<String>) -> impl Responder {
10
+ format!("Hello {}!", &name)
11
+ }
12
+
13
+ #[actix_web::main]
14
+ async fn main() -> std::io::Result<()> {
15
+ HttpServer::new(|| App::new().service(index).service(hello))
16
+ .bind(("127.0.0.1", 9090))?
17
+ .run()
18
+ .await
19
+ }