Created
February 17, 2010 12:36
-
-
Save chaliy/306563 to your computer and use it in GitHub Desktop.
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
open System.Net | |
open System.Text | |
let listen url = | |
use listener = new HttpListener() | |
listener.Prefixes.Add(url) | |
listener.Start(); | |
let context = listener.GetContext() | |
let request = context.Request | |
let response = context.Response | |
let responseString = "Hello world!"; | |
let buffer = Encoding.UTF8.GetBytes(responseString); | |
response.ContentLength64 <- buffer.LongLength | |
use output = response.OutputStream | |
output.Write(buffer, 0, buffer.Length); | |
output.Flush() | |
output.Close() | |
listener.Stop() | |
do listen "http://*:1201/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment