A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue