summaryrefslogtreecommitdiff
path: root/Omni/Jr/Web.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Jr/Web.hs')
-rw-r--r--Omni/Jr/Web.hs54
1 files changed, 54 insertions, 0 deletions
diff --git a/Omni/Jr/Web.hs b/Omni/Jr/Web.hs
new file mode 100644
index 0000000..0a00f54
--- /dev/null
+++ b/Omni/Jr/Web.hs
@@ -0,0 +1,54 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+
+-- : dep warp
+-- : dep servant-server
+-- : dep lucid
+-- : dep servant-lucid
+module Omni.Jr.Web
+ ( run,
+ defaultPort,
+ )
+where
+
+import Alpha
+import qualified Lucid
+import qualified Network.Wai.Handler.Warp as Warp
+import Servant
+import qualified Servant.HTML.Lucid as Lucid
+
+defaultPort :: Warp.Port
+defaultPort = 8080
+
+type API = Get '[Lucid.HTML] HomePage
+
+newtype HomePage = HomePage ()
+
+instance Lucid.ToHtml HomePage where
+ toHtmlRaw = Lucid.toHtml
+ toHtml (HomePage ()) =
+ Lucid.doctypehtml_ <| do
+ Lucid.head_ <| do
+ Lucid.title_ "Jr Web UI"
+ Lucid.meta_ [Lucid.charset_ "utf-8"]
+ Lucid.meta_
+ [ Lucid.name_ "viewport",
+ Lucid.content_ "width=device-width, initial-scale=1"
+ ]
+ Lucid.body_ <| do
+ Lucid.h1_ "Jr Web UI"
+
+api :: Proxy API
+api = Proxy
+
+server :: Server API
+server = pure (HomePage ())
+
+app :: Application
+app = serve api server
+
+run :: Warp.Port -> IO ()
+run port = do
+ putText <| "Starting Jr web server on port " <> tshow port
+ Warp.run port app