2021-03-24 22:07:51 +03:00
..
2021-03-08 21:58:15 +03:00
2021-03-08 21:58:15 +03:00
2021-03-08 21:58:15 +03:00
2021-03-24 22:07:51 +03:00

1-hello


This project is so simple that it doesn't even log requests!

let () =
  Dream.run (fun _ ->
    Dream.respond "Good morning, world!")

It's the absolute minimum Dream server. It responds to all requests with the same text. At startup, it prints a message to the log, telling you where to point your browser. The link is clickable in many terminals.

$ dune exec --root . ./hello.exe
08.03.21 21:17:21.471                       Running on http://localhost:8080
08.03.21 21:17:21.471                       Press ENTER to stop

If you go to http://localhost:8080, you will, of course, see Good morning, world!.


Next steps:

  • The next example, 2-middleware, adds a logger to the app.
  • 3-router sends requests to different handlers, depending on their path.

Up to the example index