6 import Control.Applicative
7 import Control.Monad.Unicode
8 import qualified Data.ByteString.Lazy.Char8 as Lazy
9 import Network.HTTP.Lucu
12 main = let config = defaultConfig { cnfServerPort = "9999" }
15 , (["urandom"], staticFile "/dev/urandom")
16 , (["inc" ], staticDir "/usr/include" )
18 fallbacks = [ \ path → case path of
19 ["hello"] → return $ Just helloWorld
23 do putStrLn "Access http://localhost:9999/ with your browser."
24 runHttpd config resources fallbacks
26 helloWorld ∷ ResourceDef
30 = Just $ do setContentType [mimeType| text/hello |]
33 putChunks =≪ Lazy.pack <$> getRemoteAddr'
35 = Just $ do str1 ← getChunk 3
38 setContentType [mimeType| text/hello |]
39 putChunks $ Lazy.fromChunks ["[", str1, " - ", str2, "#", str3, "]"]