aboutsummaryrefslogtreecommitdiff
path: root/src/mayu.gleam
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-14 03:29:38 +0000
committerFuwn <[email protected]>2026-01-14 03:29:38 +0000
commitb707f714ca36012d69cd513c901ed68f365f49c1 (patch)
tree4f598eadffd94298647c25d603fe2e725a8af66f /src/mayu.gleam
parentchore(gleam.toml): Bump version (diff)
downloadmayu-b707f714ca36012d69cd513c901ed68f365f49c1.tar.xz
mayu-b707f714ca36012d69cd513c901ed68f365f49c1.zip
perf: Optimise database queries and reduce I/O operations
Diffstat (limited to 'src/mayu.gleam')
-rw-r--r--src/mayu.gleam12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mayu.gleam b/src/mayu.gleam
index 2c3d78e..b204dc0 100644
--- a/src/mayu.gleam
+++ b/src/mayu.gleam
@@ -12,6 +12,14 @@ pub fn main() {
let _ = simplifile.create_directory("./data")
let image_cache = cache.load_themes()
+ let index_html = case simplifile.read("index.html") {
+ Ok(content) -> content
+ Error(_) -> {
+ wisp.log_error("Failed to read index.html")
+
+ ""
+ }
+ }
use connection <- sqlight.with_connection("./data/count.db")
@@ -20,7 +28,9 @@ pub fn main() {
let secret_key_base = wisp.random_string(64)
let assert Ok(_) =
wisp.mist_handler(
- fn(request) { request.handle(request, connection, image_cache) },
+ fn(request) {
+ request.handle(request, connection, image_cache, index_html)
+ },
secret_key_base,
)
|> mist.new