mirror of
https://github.com/RGBCube/GDUS
synced 2025-07-29 05:57:45 +00:00
More code
This commit is contained in:
parent
6fb17a18c6
commit
8fb68a3b7a
3 changed files with 31 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
mod index;
|
mod index;
|
||||||
mod submit;
|
mod submit;
|
||||||
|
mod view;
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ async fn main() -> io::Result<()> {
|
||||||
.service(index::index)
|
.service(index::index)
|
||||||
.service(submit::submit)
|
.service(submit::submit)
|
||||||
.service(submit::submit_form)
|
.service(submit::submit_form)
|
||||||
|
.service(view::view);
|
||||||
})
|
})
|
||||||
.bind(("127.0.0.1", 80))?
|
.bind(("127.0.0.1", 80))?
|
||||||
.run()
|
.run()
|
||||||
|
|
|
@ -6,6 +6,7 @@ use actix_web::web::{
|
||||||
use maud::{
|
use maud::{
|
||||||
html,
|
html,
|
||||||
Markup,
|
Markup,
|
||||||
|
PreEscaped,
|
||||||
DOCTYPE,
|
DOCTYPE,
|
||||||
};
|
};
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
@ -41,9 +42,9 @@ async fn submit_form(
|
||||||
(DOCTYPE)
|
(DOCTYPE)
|
||||||
h1 { "Kaydedildi." }
|
h1 { "Kaydedildi." }
|
||||||
p { "Ana sayfaya geri yönlendiriliyorsun..." }
|
p { "Ana sayfaya geri yönlendiriliyorsun..." }
|
||||||
script type="text/javascript" {r#"
|
script type="text/javascript" {(PreEscaped(r#"
|
||||||
setTimeout(() => window.location.href = "/", 5000);
|
setTimeout(function() { window.location.href = "/"; }, 5000);
|
||||||
"#}
|
"#))}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
src/view.rs
Normal file
25
src/view.rs
Normal 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!" }
|
||||||
|
})
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue