From 9c4a7fd604eafb716e9162fded33a151bd2fb515 Mon Sep 17 00:00:00 2001 From: unwox Date: Thu, 6 Jun 2024 16:08:54 +0600 Subject: simple fennel setup --- init.fnl | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'init.fnl') diff --git a/init.fnl b/init.fnl index f14817e..bce021a 100644 --- a/init.fnl +++ b/init.fnl @@ -1,9 +1,17 @@ (local fennel (require :fennel)) -{ - :routes { - :/ (fn [method path headers body] - (values 200 { :content-type "applicaton/json" } - "{ \"test\": 123 }")) - ; :/test (fn [] "test?") - } -} +(local html (require :html)) + +(local template + [:html {:lang "en"} + [:head {} + [:meta {:charset "UTF-8"}] + [:title {} "A new cool web server for lua"]] + [:body {} + [:h1 {} "Hello!"] + [:pre {} "This is my super blog!"]]]) + +(fn root-handler [method path headers body] + (let [headers { :content-type "text/html" }] + (values 200 headers (html.render template)))) + +{ :routes { :/ root-handler } } -- cgit v1.2.3