Getting Started with Wiz
A video guide is availableWiz is designed to be the simplest way to build an http server in F#.
In this doc we will start with an empty project and get a simple server running on your local machine. It is assumed that you already have .Net installed.
I. Creating an New Wiz Project
Run the following to create a scaffold for a new ASP.Net project:
dotnet new web -lang F# --name MagicalApp -o magical_app
Feel free to delete Startup.fs
, we won't be using it.
Now go into that new project directory and install the Wiz package:
dotnet add package Wiz
Replace the entire Program.fs
file with the following:
namespace MagicalApp
module Program =
open Wiz.Server
[<EntryPoint>]
let main args =
genServer() |> run
II. Start the Server
Now run the server:
dotnet watch run
watch
will cause the server to automatically restart on any changes
You should see the following output:
Building...
🔮 Wiz listening on http://localhost:9999
Now if you visit http://localhost:9999 you should see:

III. Explaining Server Configuration
The main line in the Program.fs
is:
genServer() |> run
The genServer
function creates a ServerConfig
record which we pipe into run
. To see the structure of the ServerConfig
record, let's add printConfig
between genServer
and run
:
genServer()
|> printConfig
|> run
That should print something like the following to your terminal:
{ AddServerHeader = false
Host = "127.0.0.1"
Port = 9999
StaticFileConfig = { ServeStaticFiles = false
ServeIndexFiles = true
StaticDirectoryRoot = "wwwroot"
StaticRequestPathPrefix = "" }
UseCompression = true
Routes = [(GET, "/", <fun:genServer@461>)]
DefaultStatusHandlers = map [] }
🔮 Wiz listening on http://localhost:9999
To configure our server (such as defining routes, changing the port, etc.) we just need to modify that record before passing it to run
. See Server Configuration in the API for functions to modify the ServerConfig
record.
IV. Adding a Route
Let's define a route to replace the Wiz default page. We need to add open Wiz.Route
to have access to route related functions.
Next, let's create the function we'll call whenever someone visits that route. We need to add open Wiz.Context
to import function for interacting with the HttpContext
.