1
Fork 0
mirror of https://github.com/RGBCube/GDUS synced 2025-07-29 05:57:45 +00:00

More code

This commit is contained in:
RGBCube 2023-11-24 15:42:25 +03:00
parent 6fb17a18c6
commit 8fb68a3b7a
No known key found for this signature in database
3 changed files with 31 additions and 3 deletions

View file

@ -1,5 +1,6 @@
mod index;
mod submit;
mod view;
use std::io;
@ -33,6 +34,7 @@ async fn main() -> io::Result<()> {
.service(index::index)
.service(submit::submit)
.service(submit::submit_form)
.service(view::view);
})
.bind(("127.0.0.1", 80))?
.run()

View file

@ -6,6 +6,7 @@ use actix_web::web::{
use maud::{
html,
Markup,
PreEscaped,
DOCTYPE,
};
use sqlx::SqlitePool;
@ -41,9 +42,9 @@ async fn submit_form(
(DOCTYPE)
h1 { "Kaydedildi." }
p { "Ana sayfaya geri yönlendiriliyorsun..." }
script type="text/javascript" {r#"
setTimeout(() => window.location.href = "/", 5000);
"#}
script type="text/javascript" {(PreEscaped(r#"
setTimeout(function() { window.location.href = "/"; }, 5000);
"#))}
})
}

25
src/view.rs Normal file
View file

@ -0,0 +1,25 @@
use actix_web as web;
use actix_web::web::{
Data,
Query,
};
use maud::{
html,
Markup,
DOCTYPE,
};
use sqlx::SqlitePool;
#[web::get("/")]
async fn index(data: Data<SqlitePool>) -> web::Result<Markup> {
sqlx::query_as::<(String, String)>(
r"
TODO
",
);
Ok(html! {
(DOCTYPE)
h1 { "Hello, World!" }
})
}