public static void AppTest(App app, Action innerAction) { var appThread = new Thread(() => { app.RunHttpServer(AppPrefix); }); try { appThread.Start(); innerAction(); } finally { app.Stop(); appThread.Join(); } }
static void Main(string[] args) { // Create a simple web app and serve content on to URLs. var app = new App(); // Define the URL patterns to respond to incoming requests. // Any request that does not match one of these patterns will // be served by app.NotFoundView, which defaults to a simple // 404 message. // Easiest way to respond to a request: return a string app.AddStringView("^/$", (request) => "Hello World"); // More complex response, see below app.AddStringView("^/info$", InfoView); // Start listening for HTTP requests. Default port is 8080. // This method does never return! app.RunHttpServer(); // Now you should be able to visit me in your browser on http://localhost:8080 }