Example - Hello World

The goal of this program is to demonstrate the absolute bare bones hello world application, so that we can focus on the key elements when initiating a new web application.

The code for this example can be found here.

Creating the Application Manually

> dotnet new falco -o HelloWorldApp

Code Overview

open Falco
open Falco.Routing
open Microsoft.AspNetCore.Builder
// ^-- this import adds many useful extensions

let wapp = WebApplication.Create()

wapp.UseRouting()
    .UseFalco([
    // ^-- activate Falco endpoint source
        get "/" (Response.ofPlainText "Hello World!")
        // ^-- associate GET / to plain text HttpHandler
    ])
    .Run(Response.ofPlainText "Not found")
    // ^-- activate Falco endpoint source

First, we open the required namespaces. Falco bring into scope the ability to activate the library and some other extension methods to make the fluent API more user-friendly.

Microsoft.AspNetCore.Builder enables us to create web applications in a number of ways, we're using WebApplication.Create() above. It also adds many other useful extension methods, that you'll see later.

After creating the web application, we:

Next: Example - Hello World MVC