Skip to content

Instantly share code, notes, and snippets.

@jkone27
Created January 1, 2024 23:36
Show Gist options
  • Save jkone27/f128e4a6007b9c8e1b4c881a35252905 to your computer and use it in GitHub Desktop.
Save jkone27/f128e4a6007b9c8e1b4c881a35252905 to your computer and use it in GitHub Desktop.
express js from fable using glutinum from .fsx
// npm init type module, npm add express, dotnet tool install fable, dotnet fable express.fsx, node express.fs.js
#r "nuget: Glutinum.Express, 0.1.0-alpha-002"
#r "nuget: Glutinum.BodyParser"
#r "nuget: Glutinum.RangeParser"
#r "nuget: Fable.Core"
#r "nuget: Feliz.ViewEngine"
open Glutinum.Express
open Glutinum.ExpressServeStaticCore
open Fable.Core.JsInterop
open Feliz.ViewEngine
let bodyParser = importDefault<Glutinum.BodyParser.BodyParser.IExports> "body-parser"
let app = express.express ()
app.``use`` (bodyParser.json ())
let view =
Html.body [
Html.h1 "Hello Feliz from express!"
]
|> Render.htmlView
app.get ("/", (fun (req: Request) (res: Response) -> res.send view |> ignore))
app.listen (3000, "0.0.0.0", (fun _ -> printfn "Started app at 0.0.0.0:3000"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment