Single Page Applications
Live on this serverHosts a single page application such as a React or Angular app.
Single Page Applications (SPA) Documentation
GenHTTP.Modules.SinglePageApplications Package on NuGet
using GenHTTP.Api.Content;
using GenHTTP.Modules.IO;
using GenHTTP.Modules.SinglePageApplications;
public static class SinglePageApplicationSample
{
public static IHandlerBuilder Create()
{
/*
*
* Serves a single page application (SPA) from a directory (or resource tree in general).
*
* See https://genhttp.org/documentation/content/frameworks/single-page-applications/
*
*/
// shipped with this website (resources/samples/spa), use ResourceTree.FromDirectory("/var/app") to serve your build output
var files = Resources.Tree("samples/spa");
// GET /samples/spa/books/42 serves index.html, the route is rendered in the browser
return SinglePageApplication.From(files)
.ServerSideRouting();
}
}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.
Open the application
Open a client side route directly
The server delivers the application, which then renders the route.