]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - examples/HelloWorld.hs
Network.HTTP.Lucu
[Lucu.git] / examples / HelloWorld.hs
index f3a36219fbd69fda04fefef40648dc1d5ca98b63..20be0ce1a9969dd4dc49fd0bfe5b4984fdb0ae06 100644 (file)
@@ -11,13 +11,25 @@ import Network.HTTP.Lucu.Parser.Http
 import Network.HTTP.Lucu.Resource
 import Network.HTTP.Lucu.Resource.Tree
 import Network.HTTP.Lucu.Response
+import Network.HTTP.Lucu.StaticFile
 import Network.URI
 import System.Posix.Signals
 import System.Time
 
 main :: IO ()
 main = let config    = defaultConfig { cnfServerPort = PortNumber 9999 }
-           resources = mkResTree [ ([], helloWorld) ]
+           resources = mkResTree [ ( []
+                                   , helloWorld )
+
+                                 , ( ["index.html"]
+                                   , staticFile "/Users/admin/Sites/index.html" )
+
+                                 , ( ["urandom"]
+                                   , staticFile "/dev/urandom" )
+
+                                 , ( ["inc"]
+                                   , staticDir "/usr/include" )
+                                 ]
        in
          do installHandler sigPIPE Ignore Nothing
             runHttpd config resources
@@ -29,8 +41,8 @@ helloWorld
         resUsesNativeThread = False
       , resIsGreedy         = False
       , resGet
-          = Just $ do time <- liftIO $ getClockTime
-                      foundEntity (strongETag "abcde") time
+          = Just $ do --time <- liftIO $ getClockTime
+                      --foundEntity (strongETag "abcde") time
                       setContentType $ "text" +/+ "hello"
                       outputChunk "Hello, "
                       outputChunk "World!\n"