Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,17 @@
|
|||
TCPStartup()
|
||||
$socket = TCPListen("0.0.0.0",8080)
|
||||
$string = "Goodbye, World!"
|
||||
While 1
|
||||
Do
|
||||
$newConnection = TCPAccept($socket)
|
||||
Sleep(1)
|
||||
Until $newConnection <> -1
|
||||
$content = TCPRecv($newConnection, 2048)
|
||||
If StringLen($content) > 0 Then
|
||||
TCPSend($newConnection, Binary("HTTP/1.1 200 OK" & @CRLF))
|
||||
TCPSend($newConnection, Binary("Content-Type: text/html" & @CRLF))
|
||||
TCPSend($newConnection, Binary("Content-Length: "& BinaryLen($string) & @CRLF & @CRLF))
|
||||
TCPSend($newConnection, $string)
|
||||
EndIf
|
||||
TCPCloseSocket($newConnection)
|
||||
WEnd
|
||||
|
|
@ -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