Compare commits
No commits in common. "0a6d1dc1717a750d94555f534df96b9adbe4542e" and "5dcdc6da3b2254c1403f1c3a6ce2fa2534aef764" have entirely different histories.
0a6d1dc171
...
5dcdc6da3b
3 changed files with 4 additions and 30 deletions
|
@ -10,7 +10,6 @@ mist = "~> 0.14"
|
||||||
gleam_http = "~> 3.5"
|
gleam_http = "~> 3.5"
|
||||||
wisp = "~> 0.14"
|
wisp = "~> 0.14"
|
||||||
sqlight = "~> 0.9"
|
sqlight = "~> 0.9"
|
||||||
lustre = "~> 4.1"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
gleeunit = "~> 1.0"
|
gleeunit = "~> 1.0"
|
||||||
|
|
|
@ -14,7 +14,6 @@ packages = [
|
||||||
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
|
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
|
||||||
{ name = "glisten", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "73BC09C8487C2FFC0963BFAB33ED2F0D636FDFA43B966E65C1251CBAB8458099" },
|
{ name = "glisten", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "73BC09C8487C2FFC0963BFAB33ED2F0D636FDFA43B966E65C1251CBAB8458099" },
|
||||||
{ name = "logging", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "82C112ED9B6C30C1772A6FE2613B94B13F62EA35F5869A2630D13948D297BD39" },
|
{ name = "logging", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "82C112ED9B6C30C1772A6FE2613B94B13F62EA35F5869A2630D13948D297BD39" },
|
||||||
{ name = "lustre", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "09530DF24E7E540CA59AB2486909B52EEA5C39AE1A41EBC640AD04E5418FD67A" },
|
|
||||||
{ name = "marceau", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "1AAD727A30BE0F95562C3403BB9B27C823797AD90037714255EEBF617B1CDA81" },
|
{ name = "marceau", version = "1.1.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "1AAD727A30BE0F95562C3403BB9B27C823797AD90037714255EEBF617B1CDA81" },
|
||||||
{ name = "mist", version = "0.17.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten"], otp_app = "mist", source = "hex", outer_checksum = "DA8ACEE52C1E4892A75181B3166A4876D8CBC69D555E4770250BC84C80F75524" },
|
{ name = "mist", version = "0.17.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten"], otp_app = "mist", source = "hex", outer_checksum = "DA8ACEE52C1E4892A75181B3166A4876D8CBC69D555E4770250BC84C80F75524" },
|
||||||
{ name = "simplifile", version = "1.6.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "B75D3C64E526D9D7EDEED5F3BA31DAAF5F2B4D80A4183FE17FDB02ED526E4E96" },
|
{ name = "simplifile", version = "1.6.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "B75D3C64E526D9D7EDEED5F3BA31DAAF5F2B4D80A4183FE17FDB02ED526E4E96" },
|
||||||
|
@ -28,7 +27,6 @@ gleam_erlang = { version = "~> 0.23" }
|
||||||
gleam_http = { version = "~> 3.5" }
|
gleam_http = { version = "~> 3.5" }
|
||||||
gleam_stdlib = { version = "~> 0.30" }
|
gleam_stdlib = { version = "~> 0.30" }
|
||||||
gleeunit = { version = "~> 1.0" }
|
gleeunit = { version = "~> 1.0" }
|
||||||
lustre = { version = "~> 4.1"}
|
|
||||||
mist = { version = "~> 0.14" }
|
mist = { version = "~> 0.14" }
|
||||||
sqlight = { version = "~> 0.9"}
|
sqlight = { version = "~> 0.9"}
|
||||||
wisp = { version = "~> 0.14" }
|
wisp = { version = "~> 0.14" }
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import wisp.{type Request, type Response}
|
import wisp.{type Request, type Response}
|
||||||
|
import gleam/string_builder
|
||||||
import gleam/http.{Get}
|
import gleam/http.{Get}
|
||||||
import gleam/list
|
import gleam/io
|
||||||
import gleam/result
|
|
||||||
import gleam/dynamic
|
import gleam/dynamic
|
||||||
import ring/web
|
import ring/web
|
||||||
import sqlight
|
import sqlight
|
||||||
import lustre/attribute
|
|
||||||
import lustre/element/html
|
|
||||||
import lustre/element
|
|
||||||
|
|
||||||
pub fn handle_request(req: Request) -> Response {
|
pub fn handle_request(req: Request) -> Response {
|
||||||
use req <- web.middleware(req)
|
use req <- web.middleware(req)
|
||||||
|
@ -80,28 +77,8 @@ fn home_page(req: Request) -> Response {
|
||||||
// The home page can only be accessed via GET requests, so this middleware is
|
// The home page can only be accessed via GET requests, so this middleware is
|
||||||
// used to return a 405: Method Not Allowed response for all other methods.
|
// used to return a 405: Method Not Allowed response for all other methods.
|
||||||
use <- wisp.require_method(req, Get)
|
use <- wisp.require_method(req, Get)
|
||||||
let db_path = "members.db"
|
|
||||||
use conn <- sqlight.with_connection(db_path)
|
|
||||||
let members =
|
|
||||||
sqlight.query(
|
|
||||||
"select member from ring order by member asc",
|
|
||||||
on: conn,
|
|
||||||
with: [],
|
|
||||||
expecting: dynamic.decode1(Row, dynamic.element(0, dynamic.string)),
|
|
||||||
)
|
|
||||||
let members =
|
|
||||||
result.unwrap(members, [])
|
|
||||||
|> list.map(fn(row) {
|
|
||||||
let Row(member) = row
|
|
||||||
html.li([], [html.a([attribute.href(member)], [html.text(member)])])
|
|
||||||
})
|
|
||||||
let html =
|
|
||||||
html.body([], [
|
|
||||||
html.h1([], [html.text("The Constellation Webring")]),
|
|
||||||
html.ul([], members),
|
|
||||||
])
|
|
||||||
|> element.to_document_string_builder()
|
|
||||||
|
|
||||||
|
let html = string_builder.from_string("Hello, Joe!")
|
||||||
wisp.ok()
|
wisp.ok()
|
||||||
|> wisp.html_body(html)
|
|> wisp.html_body(html)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue