gcd web p1
This commit is contained in:
parent
7a6db2e0fc
commit
dd87f1bd5d
10
gcd-web/Cargo.toml
Normal file
10
gcd-web/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "gcd-web"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
actix-web = "1.0.8"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
28
gcd-web/src/main.rs
Normal file
28
gcd-web/src/main.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let server = HttpServer::new(|| {
|
||||||
|
App::new()
|
||||||
|
.route("/", web::get().to(get_index))
|
||||||
|
});
|
||||||
|
|
||||||
|
println!("Serving on http://localhost:3300");
|
||||||
|
|
||||||
|
server.bind("127.0.0.1:3300").expect("error binding server to address")
|
||||||
|
.run().expect("error running server")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_index() -> HttpResponse {
|
||||||
|
HttpResponse::Ok()
|
||||||
|
.content_type("text/html")
|
||||||
|
.body(
|
||||||
|
r#"
|
||||||
|
<title>GCD Calculator</title>
|
||||||
|
<form action="/gcd" method="post">
|
||||||
|
<input type="text" name="a" />
|
||||||
|
<input type="text" name="b" />
|
||||||
|
<button type="submit">Compute GCD</button>
|
||||||
|
</form>
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user