Home
Insert
Update snippet 'Start and stop a Suave web server'
Title
Passcode
Description
To get a fast feedback loop going with web apps, you can run your experiments using the fsi, starting and restarting the web server each time without having to go through a slow msbuild cycle.
Source code
open Suave open Suave.Filters open Suave.Successful open System.Threading let app : WebPart = OK "All good" let cancellationTokenSource = new CancellationTokenSource () let config = { defaultConfig with cancellationToken = cancellationTokenSource.Token } let _, webServer = startWebServerAsync config app Async.Start (webServer, cancellationTokenSource.Token) |> ignore (* stops the server *) cancellationTokenSource.Cancel ()
Tags
web
web
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update