Getting Started
Using dotnet new
The easiest way to get started with Falco is by installing the Falco.Template
package, which adds a new template to your dotnet new
command line tool:
> dotnet new -i "Falco.Template::*"
Afterwards you can create a new Falco application by running:
> dotnet new falco -o HelloWorldApp
> cd HelloWorldApp
> dotnet run
Manually installing
Create a new F# web project:
> dotnet new web -lang F# -o HelloWorldApp
> cd HelloWorldApp
Install the nuget package:
> dotnet add package Falco
Remove any *.fs
files created automatically, create a new file named Program.fs
and set the contents to the following:
open Falco
open Falco.Routing
open Microsoft.AspNetCore.Builder
// ^-- this import adds many useful extensions
let endpoints =
[
get "/" (Response.ofPlainText "Hello World!")
// ^-- associate GET / to plain text HttpHandler
]
let wapp = WebApplication.Create()
wapp.UseRouting()
.UseFalco(endpoints)
// ^-- activate Falco endpoint source
.Run()
Run the application:
> dotnet run
And there you have it, an industrial-strength Hello World web app. Pretty sweet!
Sample Applications
Code is worth a thousand words. For the most up-to-date usage, the examples directory contains a few sample applications.