Why bother with a dedicated web server when Warp 10 can host your Web content?

We introduced the Warp 10 HTTP Plugin in 2018 as part of the 2.0 release. This post aims at demonstrating how you can use this plugin to host the content of a complete website. As an immediate spoiler, know that the Warp 10 Sandbox is entirely hosted on Warp 10.
Overview
The HTTP Plugin works by executing WarpScript code for specific HTTP requests, passing the parameters to the said code. The idea behind the hosting of any Web content in Warp 10 is to define a set of macros, one for each resource you want to serve, and to call those macros from the routing macro defined in your HTTP Plugin configuration.
Generating content macros
Each static resource in your Web content should be converted to a WarpScript macro. The behavior of those macros is very simple. They simply return the content of the original file from which they were generated.
As an example, the macro for the Sandbox main page is:
This macro returns a byte array containing the actual page. This macro is available on the sandbox as @sandbox.senx.io/index.html. The content returned by this macro will be returned by the routing macro to the requesting browser, along with the right set of HTTP headers.
The following shell script will generate WarpScript macros for a hierarchy of files. Run it from the root of the content you wish to convert and pipe its output to a tar -cT -
command to create an archive of all the generated macros.
On the machine running your Warp 10 instance, create a directory under macros
and untar the content of the archive you just created. We will assume the directory you created is called webcontent.
Declaring a routing macro
Now that you have converted your content, you need to configure the HTTP Plugin to serve it. You can do it in two steps. First you have to enable the HTTP Plugin, then you need to create a WarpScript file describing how you will serve your content. Such a file is shown below:
Profit!
That's all there is to it! You can now very easily host your Web content entirely in Warp 10 and not rely on an external web server, thus simplifying your overall infrastructure.
Read more

Co-Founder & Chief Technology Officer