5 import Control.Applicative
6 import Control.Monad.Unicode
7 import qualified Data.ByteString.Lazy.Char8 as Lazy
8 import Data.Monoid.Unicode
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
27 helloWorld ∷ ResourceDef
31 = Just $ do setContentType $ parseMIMEType "text/hello"
33 outputChunk "World!\n"
34 outputChunk =≪ Lazy.pack <$> getRemoteAddr'
36 = Just $ do str1 ← inputChunk 3
39 setContentType $ parseMIMEType "text/hello"
40 output ("[" ⊕ str1 ⊕ " - " ⊕ str2 ⊕ "#" ⊕ str3 ⊕ "]")