Static Websites

Live on this server

Hosts a static website, with index.html support.

StaticWebsiteSample.cs26 lines
using GenHTTP.Api.Content;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.StaticWebsites;

public static class StaticWebsiteSample
{

    public static IHandlerBuilder Create()
    {
        /*
         *
         * Serves a static website from a directory (or resource tree in general).
         *
         * See https://genhttp.org/documentation/content/frameworks/static-websites/
         *
         */

        // shipped with this website (resources/samples/website), use ResourceTree.FromDirectory("/var/www") to serve a folder
        var files = Resources.Tree("samples/website");

        // GET /samples/static-website/ serves index.html
        return StaticWebsite.From(files);
    }

}

Try it

Send the requests to the sample running on this server - change the path, headers or body as you like, or copy them as curl commands.

  1. Open the website

    PAGE /samples/static-website/ Open