shaarli_cgi.ml 840 B

12345678910111213141516171819202122232425262728293031323334353637
  1. (*
  2. * https://caml.inria.fr/pub/docs/u3-ocaml/ocaml-steps.html
  3. *
  4. * extract some stuff about the request:
  5. * - method
  6. * - request uri
  7. * - header
  8. * - cookie(s)
  9. * - POST form data
  10. *
  11. * Response:
  12. * - http status + reason
  13. * - header
  14. * - content-type
  15. * - server
  16. * - body
  17. * - xml+atom (syndic) with xslt and comment prefix,
  18. * - xhtml or
  19. * - text/plain
  20. *
  21. * http://cumulus.github.io/Syndic/syndic/Syndic__/Syndic_atom/#input-and-output
  22. *
  23. * other cgi lib:
  24. * https://gitlab.com/gerdstolpmann/lib-ocamlnet3/blob/master/code/examples/cgi/netcgi2/add.ml
  25. * http://projects.camlcity.org/projects/dl/ocamlnet-4.1.6/doc/html-main/Netcgi.html#TYPEexn_handler
  26. *)
  27. open Lib
  28. let () =
  29. let status =
  30. match Sys.getenv_opt Cgi.http_request_method with
  31. | Some _ -> Cgi.run()
  32. | None -> Shell.run() in
  33. exit status;;