Home

Awesome

Rebol-HTTPd CI Zulip

Rebol/HTTPd

A Webserver Scheme for Rebol3. Based on 'A Tiny HTTP Server' by Andreas Bolka and Christopher Ross-Gill's Adaptation to Scheme made as a part of Oldes' Rebol3 sources as a more feature complete web server. Now having its own home here to better track future improvements.

Features:

TODO:

History:

Usage:

  1. Minimal server setup for serving content of the current directory on port 8000:
serve-http 8000
  1. Minimal server setup for serving content of the specified directory on default port 8000
serve-http %hosts/test/
  1. Simple server setup for in-memory generated content (root-less)
serve-http [port: 8000 actor: [
    On-Get: func [ctx][
        ;; just responding with the content we received...
        ctx/out/content: mold ctx/inp
    ]
    On-Post: func[ctx][
        ;; responding with a parsed content; including a custom message in the header...
        ctx/out/header/X-Response: "Just a custom message in the header."
        ctx/out/content: mold ctx/inp/content
    ]
]]

At this moment there are these actors which may be used:

For more complete server setup check server-test.r3 script.

Setup a service on Linux

The best way to start a Linux service that persists through a boot is to create a systemd service. Here are the steps to create a systemd service:

  1. Create a new service file in the /etc/systemd/system directory using a text editor. For example, create a file named mywebserver.service.

  2. Inside the service file, define the service by providing a [Unit] section with a Description and After directive, and a [Service] section with the ExecStart directive. For example:

[Unit]
Description=My Rebol Web Server
After=network.target

[Service]
ExecStart=/usr/local/bin/rebol3 -qs /path/to/server/script.r3
Restart=always
User=rebol
Group=www-data

[Install]
WantedBy=multi-user.target
  1. Save the service file and reload the systemd daemon to pick up the new service:
sudo systemctl daemon-reload
  1. Enable the service to start at boot:
sudo systemctl enable mywebserver.service
  1. Start the service:
sudo systemctl start mywebserver.service

The service should now be running and will start automatically on boot. You can use the systemctl command to manage the service, such as to stop or restart it:

sudo systemctl stop mywebserver.service
sudo systemctl restart mywebserver.service

Or to get a status of the service:

sudo systemctl status mywebserver.service