blob: 4ba5fb7c6b6d68082857794620651e18f22d1cc4 (
plain)
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
|
(* let home request = *)
(* <html> *)
(* <body> *)
(* <form method="POST" action="/" enctype="multipart/form-data"> *)
(* <%s! Dream.csrf_tag request %> *)
(* <input name="files" type="file" multiple> *)
(* <button>Submit!</button> *)
(* </form> *)
(* </body> *)
(* </html> *)
(* let report files = *)
(* <html> *)
(* <body> *)
(* % files |> List.iter begin fun (name, content) -> *)
(* % let name = *)
(* % match name with *)
(* % | None -> "None" *)
(* % | Some name -> name *)
(* % in *)
(* <p><%s name %>, <%i String.length content %> bytes</p> *)
(* % end; *)
(* </body> *)
(* </html> *)
(* let uploads = *)
(* [ *)
(* Dream.get "/" (fun request -> *)
(* Dream.html (home request)); *)
(* Dream.post "/" (fun request -> *)
(* match%lwt Dream.multipart request with *)
(* | `Ok ["files", files] -> Dream.html (report files) *)
(* | _ -> Dream.empty `Bad_Request); *)
(* ] *)
|