Instantly share code, notes, and snippets.

Embed
What would you like to do?
HTTPd Example for Ren-C
#!/usr/local/bin/ren-c
Rebol [
Title: "HTTPd Example"
Date: 7-Feb-2018
Author: "Christopher Ross-Gill"
File: %httpd-example.reb
Rights: http://opensource.org/licenses/Apache-2.0
Needs: [<httpd>]
]
also: lib/also: func [value1 value2][value1]
server: open [
scheme: 'httpd 8080 [
if switch request/action [
"GET /" [
response/content: {
<!DOCTYPE html>
<html>
... html page ...
</html>
}
]
"GET /favicon.ico" [
response/type: "image/png"
response/content: #{} ; read http://rebol.info/assets/rebolbot.png
]
"GET /build.js" [
response/type: "text/javascript"
response/content: #{} ; contents of the build
]
][
response/status: 200
]
]
]
browse http://localhost:8080/
wait server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment