Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.ByteString.Char8 ()
|
||||
import Data.Conduit ( ($$), yield )
|
||||
import Data.Conduit.Network ( ServerSettings(..), runTCPServer )
|
||||
|
||||
main :: IO ()
|
||||
main = runTCPServer (ServerSettings 8080 "127.0.0.1") $ const (yield response $$)
|
||||
where response = "HTTP/1.0 200 OK\nContent-Length: 16\n\nGoodbye, World!\n"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Data.ByteString.Char8 ()
|
||||
import Network hiding ( accept )
|
||||
import Network.Socket ( accept )
|
||||
import Network.Socket.ByteString ( sendAll )
|
||||
import Control.Monad ( forever )
|
||||
import Control.Exception ( bracket, finally )
|
||||
import Control.Concurrent ( forkIO )
|
||||
|
||||
main :: IO ()
|
||||
main = bracket (listenOn $ PortNumber 8080) sClose loop where
|
||||
loop s = forever $ forkIO . request . fst =<< accept s
|
||||
request c = sendAll c response `finally` sClose c
|
||||
response = "HTTP/1.0 200 OK\nContent-Length: 16\n\nGoodbye, World!\n"
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
import Network.Wai
|
||||
import Network.Wai.Handler.Warp
|
||||
import Network.HTTP.Types (status200)
|
||||
import Blaze.ByteString.Builder (copyByteString)
|
||||
import qualified Data.ByteString.UTF8 as BU
|
||||
import Data.Monoid
|
||||
|
||||
main = do
|
||||
let port = 8080
|
||||
putStrLn $ "Listening on port " ++ show port
|
||||
run port app
|
||||
|
||||
app req respond = respond $
|
||||
case pathInfo req of
|
||||
x -> index x
|
||||
|
||||
index x = responseBuilder status200 [("Content-Type", "text/plain")] $ mconcat $ map copyByteString
|
||||
[ "Hello World!\n" ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue