Skip to content

dbrattli/Fable.Giraffe

Repository files navigation

Fable.Giraffe

Build and Test Nuget

Fable.Giraffe is a port of the Giraffe F# web framework to Fable. Write your web application once in F# and run it on Python (ASGI/uvicorn) or Erlang/BEAM (Cowboy).

Example

let webApp =
    choose [
        route "/ping" >=> text "pong"
        route "/json" >=> json {| name = "Dag"; age = 53 |}
    ]

let app =
    WebHostBuilder()
        .Configure(fun app -> app.UseGiraffe(webApp))
        .Build()

Prerequisites

  • .NET SDK 8+
  • Python >= 3.12 with uv
  • Erlang/OTP 28+ (for BEAM target)

Build

just setup     # restore dotnet tools + uv sync
just build     # compile F# library to Python (output: build/lib/)
just build-beam  # compile F# library to Erlang (output: build/beam/)

For local Fable development (using a local Fable compiler checkout):

just dev=true build

Running

Python (ASGI)

just app

This compiles the example app and starts it with uvicorn on port 8080.

Erlang/BEAM (Cowboy)

just app-beam

This compiles the example app to Erlang, builds with rebar3, and starts a Cowboy server on port 8080.

Testing

just test          # native F# tests + compiled Python tests
just test-native   # native F# tests only (xUnit)
just test-python   # compiled Python tests only (pytest)

Benchmarks

Simple /ping endpoint returning "pong", 10,000 requests with 100 concurrent connections (oha):

Metric BEAM .NET Python
Requests/sec 124,256 70,375 4,006
Avg latency 0.79 ms 1.40 ms 24.9 ms
P99 latency 2.49 ms 3.50 ms 34.2 ms

BEAM: Erlang/OTP 28, Cowboy. .NET: Giraffe on ASP.NET Core. Python: uvicorn, 1 worker.

About

Giraffe for Fable (Python and BEAM)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages