{-# 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