Skip to content

Instantly share code, notes, and snippets.

@pizycki
Last active March 27, 2019 18:03
Show Gist options
  • Select an option

  • Save pizycki/451471c41bcdb11ffed2ec1bc426c3ee to your computer and use it in GitHub Desktop.

Select an option

Save pizycki/451471c41bcdb11ffed2ec1bc426c3ee to your computer and use it in GitHub Desktop.
NanoWebServer.fs
open Suave
open Argu
type Args =
| [<EqualsAssignment>] IP of host:string
| [<EqualsAssignment>] Port of port:int
with
interface IArgParserTemplate with
member s.Usage =
match s with
| IP _ -> "Address where WebAPI will be available."
| Port _ -> "WebAPI port."
[<EntryPoint>]
let main argv =
let parser = ArgumentParser.Create<Args>()
let args = parser.Parse argv
let host = args.GetResult IP
let port = args.GetResult Port
startWebServer {
defaultConfig with
bindings = [ HttpBinding.createSimple HTTP host port ]
} (Successful.OK "Hello from NanoWebServer!")
0
NanoWebServer.exe --ip=127.0.0.1 --port=8082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment