-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.fs
37 lines (32 loc) · 1.16 KB
/
App.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace HelloWorld.Interstellar
open System
open System.Reflection
open System.IO
open Interstellar
open Suave
module WebServer =
open Suave.Filters
open Suave.Operators
let app : WebPart =
choose [
GET >=> path "/" >=> Files.file "index.html"
GET >=> Files.browseHome
RequestErrors.NOT_FOUND "Page not found."
]
let config wwwroot =
{ defaultConfig with homeFolder = Some wwwroot }
let startAsync wwwroot =
printfn "wwwroot is: %s" wwwroot
startWebServerAsync (config wwwroot) app
module App =
let app resourcesPath = {
onStart = fun mainCtx createWindow -> async {
let listening, closedHandle = WebServer.startAsync (Path.Combine (resourcesPath, "wwwroot"))
let! closedHandle = Async.StartChild closedHandle
let! _ = listening
do! Async.SwitchToContext mainCtx
let window = createWindow { BrowserWindowConfig.defaultValue with address = Some (Uri "http://localhost:8080/index.html"); showDevTools = true }
do! window.Show ()
do! Async.AwaitEvent window.Closed
}
}