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 [ ( []
24 , staticFile "/etc/compilers" )
27 do installHandler sigPIPE Ignore Nothing
28 runHttpd config resources
31 helloWorld :: ResourceDef
34 resUsesNativeThread = False
37 = Just $ do time <- liftIO $ getClockTime
38 foundEntity (strongETag "abcde") time
39 setContentType $ "text" +/+ "hello"
41 outputChunk "World!\n"
44 = Just $ do str1 <- inputChunk 3
47 setContentType $ "text" +/+ "hello"
48 output ("[" ++ str1 ++ " - " ++ str2 ++ "#" ++ str3 ++ "]")