Created
July 30, 2011 08:49
-
-
Save 7sharp9/1115343 to your computer and use it in GitHub Desktop.
F# Web server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let server = HttpServer((fun(headers, close, svr, sd) -> | |
let header = sprintf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: 20\r\nConnection: close\r\nServer: Fracture\r\nDate: %s\r\n\r\n" (DateTime.UtcNow.ToShortDateString()) | |
let body = "Hello world.\r\nHello." | |
let encoded = System.Text.Encoding.ASCII.GetBytes(header + body) | |
do svr.Send(sd.RemoteEndPoint, encoded, true)), body = fun(body, svr, sd) -> | |
Debug.WriteLine( sprintf "%s" (Text.Encoding.ASCII.GetString(body.Array)) ) ) | |
server.Listen(6667) | |
printfn "Http Server started" | |
Console.ReadKey() |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment