From 7c6fd4b424d5ec1701a5a42f4e305bb2e4492145 Mon Sep 17 00:00:00 2001 From: elioat Date: Fri, 8 Dec 2023 22:33:59 -0500 Subject: * --- bb/web/htmx.clj | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'bb/web/htmx.clj') diff --git a/bb/web/htmx.clj b/bb/web/htmx.clj index 772da25..3294e2d 100644 --- a/bb/web/htmx.clj +++ b/bb/web/htmx.clj @@ -2,15 +2,35 @@ (require '[babashka.deps :as deps]) (deps/add-deps '{:deps {org.clojars.askonomm/ruuter {:mvn/version "1.3.2"}}}) - (require '[org.httpkit.server :as srv] '[clojure.java.browse :as browse] '[ruuter.core :as ruuter] - '[clojure.pprint :refer [cl-format]] - '[clojure.string :as str] '[hiccup.core :as h]) -(import '[java.net URLDecoder]) - (def port 3000) +(defn index [] + (list + "" + (h/html + [:head + [:meta {:charset "UTF-8"}] + [:title "Babashka"]] + [:body + [:section.main + [:header.header + [:h1 "hullo, frodo!"]]]]))) + +(def routes [{:path "/" + :method :get + :response {:body (index) + :status 200 + :headers {"Content-Type" "text/html; charset=utf-8"}}}]) + +;; Server +(when (= *file* (System/getProperty "babashka.file")) + (let [url (str "http://localhost:" port "/")] + (srv/run-server #(ruuter/route routes %) {:port port}) + (println "serving" url) + (browse/browse-url url) + @(promise))) \ No newline at end of file -- cgit 1.4.1-2-gfad0