Created
October 13, 2012 20:31
-
-
Save hbbio/3886045 to your computer and use it in GitHub Desktop.
This file contains 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
Server.start( | |
Server.http, | |
{ ~dispatch } | |
) | |
choices = ["hello world", "goodbye world"] | |
index = string_of_binary(File.read("index.html")) | |
function dispatch(Uri.relative url) { | |
match (url) { | |
case {path: ["getstring"] ...}: | |
string = Option.default("", List.random_elt(choices)); | |
Resource.source(string, "text/plain") | |
default: | |
Resource.source(index, "text/html") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment