5 import Control.Applicative
6 import Control.Monad.Unicode
7 import qualified Data.ByteString.Lazy.Char8 as Lazy
8 import Network.HTTP.Lucu
11 main = let config = defaultConfig { cnfServerPort = "9999" }
14 , (["urandom"], staticFile "/dev/urandom")
15 , (["inc" ], staticDir "/usr/include" )
17 fallbacks = [ \ path → case path of
18 ["hello"] → return $ Just helloWorld
22 do putStrLn "Access http://localhost:9999/ with your browser."
23 runHttpd config resources fallbacks
25 helloWorld ∷ ResourceDef
29 = Just $ do setContentType $ parseMIMEType "text/hello"
32 putChunks =≪ Lazy.pack <$> getRemoteAddr'
34 = Just $ do str1 ← getChunk 3
37 setContentType $ parseMIMEType "text/hello"
38 putChunks $ Lazy.fromChunks ["[", str1, " - ", str2, "#", str3, "]"]