<div dir="ltr"><div><div><div>Hi All,<br><br></div>I just cobbled together the code below from a couple of samples, but got the types matched up by trial and error. I don&#39;t really understand when things are getting converted between lazy, strict, utf8, ascii, etc. I don&#39;t want ascii in the served page at all. Is it optimal?<br>
<br></div>TIA,<br></div>Adrian<br><br><span style="font-family:comic sans ms,sans-serif">{-# LANGUAGE OverloadedStrings #-}<br><br>module Main where <br><br>import Network.Wai (Application, Response (ResponseBuilder)) <br>
import Network.HTTP.Types (status200) <br>import Network.HTTP.Types.Header (hContentType, hContentLength, hConnection) <br>import Network.Wai.Handler.Warp (run) <br>import Blaze.ByteString.Builder (fromByteString, fromLazyByteString) <br>
import qualified Data.ByteString.Char8 as BS (pack, length) <br><br>import qualified Text.Blaze.Html5 as H<br>import qualified Text.Blaze.Html5.Attributes as A<br>import Text.Blaze.Html.Renderer.Utf8<br><br>import qualified Data.ByteString.Lazy as LB<br>
<br>application:: Application <br>application _ = return $   <br>    ResponseBuilder status200 [(hContentType, BS.pack &quot;text/html&quot;),  <br>                               (hContentLength, BS.pack bodyLen),  <br>                               (hConnection, BS.pack &quot;keep-alive&quot;)]  <br>
                    $ fromLazyByteString body <br>    where body = root<br>          bodyLen = show. LB.length $ body <br><br>root = renderHtml rooth<br><br>rooth :: H.Html<br>rooth = H.docTypeHtml $ do<br>    H.body $ do<br>
        H.h1 &quot;Hello&quot;<br><br>main:: IO ()  <br>main = run 8080 application <br><br></span><br></div>