|
|
@ -1,6 +1,7 @@
|
|
|
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
|
|
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
#[actix_web::main]
|
|
|
|
|
|
|
|
async fn main() {
|
|
|
|
let server = HttpServer::new(|| {
|
|
|
|
let server = HttpServer::new(|| {
|
|
|
|
App::new()
|
|
|
|
App::new()
|
|
|
|
.route("/", web::get().to(get_index))
|
|
|
|
.route("/", web::get().to(get_index))
|
|
|
@ -10,10 +11,12 @@ fn main() {
|
|
|
|
println!("Serving on http://localhost:3000...");
|
|
|
|
println!("Serving on http://localhost:3000...");
|
|
|
|
server
|
|
|
|
server
|
|
|
|
.bind("127.0.0.1:3000").expect("error binding server to address")
|
|
|
|
.bind("127.0.0.1:3000").expect("error binding server to address")
|
|
|
|
.run().expect("error running server");
|
|
|
|
.run()
|
|
|
|
|
|
|
|
.await
|
|
|
|
|
|
|
|
.expect("error running server");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn get_index() -> HttpResponse {
|
|
|
|
async fn get_index() -> HttpResponse {
|
|
|
|
HttpResponse::Ok()
|
|
|
|
HttpResponse::Ok()
|
|
|
|
.content_type("text/html")
|
|
|
|
.content_type("text/html")
|
|
|
|
.body(
|
|
|
|
.body(
|
|
|
@ -35,7 +38,7 @@ struct GcdParameters {
|
|
|
|
m: u64,
|
|
|
|
m: u64,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn post_gcd(form: web::Form<GcdParameters>) -> HttpResponse {
|
|
|
|
async fn post_gcd(form: web::Form<GcdParameters>) -> HttpResponse {
|
|
|
|
if form.n == 0 || form.m == 0 {
|
|
|
|
if form.n == 0 || form.m == 0 {
|
|
|
|
return HttpResponse::BadRequest()
|
|
|
|
return HttpResponse::BadRequest()
|
|
|
|
.content_type("text/html")
|
|
|
|
.content_type("text/html")
|
|
|
|