Skip to content

Instantly share code, notes, and snippets.

@rgchris
Last active February 7, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgchris/e0d490c09852c169ce8d42d5eb89ab20 to your computer and use it in GitHub Desktop.
Save rgchris/e0d490c09852c169ce8d42d5eb89ab20 to your computer and use it in GitHub Desktop.
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