From 1171a1be0dce83819965cf85bf79ba483e1a44cc Mon Sep 17 00:00:00 2001 From: Taran Nathan Date: Thu, 11 Jun 2026 15:26:18 -0400 Subject: [PATCH] file list --- src/router.gleam | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/router.gleam b/src/router.gleam index 2036bc7..cd1aad3 100644 --- a/src/router.gleam +++ b/src/router.gleam @@ -21,11 +21,32 @@ pub fn handle_request( wisp.ok() } "/new/" <> _path -> upload(req, password) + "/list" -> list(req, file_path) "/files/" <> path -> files(req, "/" <> path, file_path) _ -> wisp.not_found() } } +fn list(req: wisp.Request, file_path: String) -> wisp.Response { + let files = simplifile.get_files(file_path) |> result.unwrap([]) + + let formatted = + files + |> list.fold("", fn(acc, file) { + acc + <> html_linkify( + file |> string.split("/") |> list.last |> result.unwrap(""), + ) + }) + + wisp.html_response("

FILE LIST!

", 200) +} + +fn html_linkify(file: String) -> String { + echo file + echo " file <> "\">" <> file <> "
" +} + fn files(req: wisp.Request, path: String, file_path) -> wisp.Response { //TODO case req.headers smth smth use <- wisp.serve_static(req, "/files", file_path) -- 2.47.3