mirror of
https://github.com/RGBCube/GDUS
synced 2025-07-28 13:37:45 +00:00
Add prototype code
This commit is contained in:
parent
2d5b3b2e6c
commit
45a48e1e9d
5 changed files with 877 additions and 209 deletions
979
Cargo.lock
generated
979
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,5 +8,10 @@ version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.6.20"
|
actix-web = "4.4.0"
|
||||||
maud = { version = "0.25.0", features = [ "axum" ] }
|
maud = { version = "0.25.0", features = [ "actix-web" ] }
|
||||||
|
serde = { version = "1.0.192", features = [ "derive" ] }
|
||||||
|
tokio = { version = "1.34.0", features = [ "full" ] }
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
incremental = true
|
||||||
|
|
14
src/index.rs
Normal file
14
src/index.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use actix_web as web;
|
||||||
|
use maud::{
|
||||||
|
html,
|
||||||
|
Markup,
|
||||||
|
DOCTYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[web::get("/")]
|
||||||
|
async fn index() -> web::Result<Markup> {
|
||||||
|
Ok(html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
h1 { "Hello, World!" }
|
||||||
|
})
|
||||||
|
}
|
39
src/main.rs
39
src/main.rs
|
@ -1,24 +1,19 @@
|
||||||
use axum::{
|
mod index;
|
||||||
routing,
|
mod submit;
|
||||||
Router,
|
|
||||||
};
|
|
||||||
use maud::{
|
|
||||||
html,
|
|
||||||
Markup,
|
|
||||||
};
|
|
||||||
|
|
||||||
async fn index() -> Markup {
|
use std::io;
|
||||||
html! {
|
|
||||||
h1 { "Hello, World!" }
|
use actix_web as web;
|
||||||
}
|
|
||||||
}
|
#[web::main]
|
||||||
|
async fn main() -> io::Result<()> {
|
||||||
#[tokio::main]
|
web::HttpServer::new(|| {
|
||||||
async fn main() {
|
web::App::new()
|
||||||
let app = Router::new().route("/", routing::get(index));
|
.service(index::index)
|
||||||
|
.service(submit::submit)
|
||||||
axum::Server::bind(&"0.0.0.0:80".parse().unwrap())
|
.service(submit::submit_form)
|
||||||
.serve(app.into_make_service())
|
})
|
||||||
.await
|
.bind(("127.0.0.1", 80))?
|
||||||
.unwrap();
|
.run()
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
45
src/submit.rs
Normal file
45
src/submit.rs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
use actix_web as web;
|
||||||
|
use actix_web::web::Query;
|
||||||
|
use maud::{
|
||||||
|
html,
|
||||||
|
Markup,
|
||||||
|
DOCTYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
pub struct Reminder {
|
||||||
|
date: String,
|
||||||
|
message: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[web::get("/submit-form")]
|
||||||
|
async fn submit_form(Query(reminder): Query<Reminder>) -> web::Result<Markup> {
|
||||||
|
println!("{reminder:?}");
|
||||||
|
|
||||||
|
Ok(html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
h1 { "Kaydedildi." }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[web::get("/submit")]
|
||||||
|
async fn submit() -> web::Result<Markup> {
|
||||||
|
Ok(html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
form action="/submit-form" {
|
||||||
|
ul {
|
||||||
|
li class="li-button" {
|
||||||
|
button type="submit" { "Kaydet" }
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
label for="date" { "Tarih:" }
|
||||||
|
input type="datetime-local" id="date" name="date";
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
label for="message" { "Mesaj:" }
|
||||||
|
input id="message" name="message";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue