mirror of
https://github.com/aantron/dream.git
synced 2025-12-31 00:03:52 -05:00
e-json
TODO
let show_form ?message request =
<html>
<body>
% begin match message with
% | None -> ()
% | Some message ->
<p>You entered: <b><%s message %>!</b></p>
% end;
<%s! Dream.Tag.form ~action:"/" request %>
<input name="message" autofocus>
</form>
</body>
</html>
let () =
Dream.run
@@ Dream.logger
@@ Dream.sessions_in_memory
@@ Dream.router [
Dream.get "/"
(fun request ->
Dream.respond (show_form request));
Dream.post "/"
(fun request ->
match%lwt Dream.form request with
| `Ok ["message", message] ->
Dream.respond (show_form ~message request)
| _ ->
Dream.empty `Bad_Request);
]
@@ Dream.not_found
$ dune exec --root . ./promise.exe
TODO
Next steps:
b-sessionintroduces session management for associating state with clients.c-cookieshows cookie handling in Dream.