1 import Control.Monad.Trans
4 import Network.HTTP.Lucu.Config
5 import Network.HTTP.Lucu.ETag
6 import Network.HTTP.Lucu.Httpd
7 import Network.HTTP.Lucu.MIMEType
8 import Network.HTTP.Lucu.MIMEType.Guess
9 import Network.HTTP.Lucu.Parser
10 import Network.HTTP.Lucu.Parser.Http
11 import Network.HTTP.Lucu.Resource
12 import Network.HTTP.Lucu.Resource.Tree
13 import Network.HTTP.Lucu.Response
14 import Network.HTTP.Lucu.StaticFile
16 import System.Posix.Signals
20 main = let config = defaultConfig { cnfServerPort = PortNumber 9999 }
21 resources = mkResTree [ ( []
25 , staticFile "/Users/admin/Sites/index.html" )
28 , staticFile "/dev/urandom" )
31 , staticDir "/usr/include" )
34 do installHandler sigPIPE Ignore Nothing
35 runHttpd config resources
38 helloWorld :: ResourceDef
41 resUsesNativeThread = False
44 = Just $ do time <- liftIO $ getClockTime
45 foundEntity (strongETag "abcde") time
46 setContentType $ "text" +/+ "hello"
48 outputChunk "World!\n"
51 = Just $ do str1 <- inputChunk 3
54 setContentType $ "text" +/+ "hello"
55 output ("[" ++ str1 ++ " - " ++ str2 ++ "#" ++ str3 ++ "]")