mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-12-22 05:55:50 +00:00
Day 14
This commit is contained in:
parent
ee0e3042bb
commit
320360ac9e
75
Cargo.lock
generated
75
Cargo.lock
generated
|
@ -72,6 +72,61 @@ version = "0.7.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||
|
||||
[[package]]
|
||||
name = "askama"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
|
||||
dependencies = [
|
||||
"askama_derive",
|
||||
"askama_escape",
|
||||
"humansize",
|
||||
"num-traits",
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_axum"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a41603f7cdbf5ac4af60760f17253eb6adf6ec5b6f14a7ed830cf687d375f163"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"axum-core 0.4.1",
|
||||
"http 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_derive"
|
||||
version = "0.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a0fc7dcf8bd4ead96b1d36b41df47c14beedf7b0301fc543d8f2384e66a2ec0"
|
||||
dependencies = [
|
||||
"askama_parser",
|
||||
"basic-toml",
|
||||
"mime",
|
||||
"mime_guess",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"syn 2.0.39",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "askama_escape"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
|
||||
|
||||
[[package]]
|
||||
name = "askama_parser"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c268a96e01a4c47c8c5c2472aaa570707e006a875ea63e819f75474ceedaf7b4"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-stream"
|
||||
version = "0.3.5"
|
||||
|
@ -293,6 +348,15 @@ version = "1.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "basic-toml"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f2139706359229bfa8f19142ac1155b4b80beafb7a60471ac5dd109d4a19778"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.2"
|
||||
|
@ -360,6 +424,8 @@ dependencies = [
|
|||
name = "cch23-8bit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"askama",
|
||||
"askama_axum",
|
||||
"axum 0.7.2",
|
||||
"axum-extra",
|
||||
"base64",
|
||||
|
@ -1152,6 +1218,15 @@ version = "1.0.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
||||
dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.27"
|
||||
|
|
|
@ -4,6 +4,8 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
askama = { version = "0.12.1", features = ["with-axum"] }
|
||||
askama_axum = "0.4.0"
|
||||
axum = { version = "0.7.2", features = ["macros", "multipart"] }
|
||||
axum-extra = { version = "0.9.0", features = ["typed-header"] }
|
||||
base64 = "0.21.5"
|
||||
|
|
2
askama.toml
Normal file
2
askama.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[general]
|
||||
dirs = ["src/assets"]
|
8
src/assets/day14/index.html
Normal file
8
src/assets/day14/index.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>CCH23 Day 14</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ content }}
|
||||
</body>
|
||||
</html>
|
37
src/cal/day14.rs
Normal file
37
src/cal/day14.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
use axum::{response::IntoResponse, routing::post, Json, Router};
|
||||
|
||||
pub(crate) fn router() -> Router {
|
||||
Router::new()
|
||||
.route("/14/unsafe", post(unsafefn))
|
||||
.route("/14/safe", post(safefn))
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct Content {
|
||||
content: String,
|
||||
}
|
||||
|
||||
#[derive(askama::Template)]
|
||||
#[template(path = "day14/index.html", escape = "none")]
|
||||
struct UnsafeTemplate {
|
||||
content: String,
|
||||
}
|
||||
|
||||
async fn unsafefn(Json(content): Json<Content>) -> impl IntoResponse {
|
||||
UnsafeTemplate {
|
||||
content: content.content,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(askama::Template)]
|
||||
#[template(path = "day14/index.html")]
|
||||
struct SafeTemplate {
|
||||
content: String,
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
async fn safefn(Json(content): Json<Content>) -> impl IntoResponse {
|
||||
SafeTemplate {
|
||||
content: content.content,
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ mod day08;
|
|||
mod day11;
|
||||
mod day12;
|
||||
mod day13;
|
||||
mod day14;
|
||||
|
||||
pub(crate) fn router(pool: sqlx::PgPool) -> axum::Router {
|
||||
axum::Router::new()
|
||||
|
@ -19,4 +20,5 @@ pub(crate) fn router(pool: sqlx::PgPool) -> axum::Router {
|
|||
.nest("/", day11::router())
|
||||
.nest("/", day12::router())
|
||||
.nest("/", day13::router(pool))
|
||||
.nest("/", day14::router())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue