Created
January 1, 2024 23:36
-
-
Save jkone27/f128e4a6007b9c8e1b4c881a35252905 to your computer and use it in GitHub Desktop.
express js from fable using glutinum from .fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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