To install Eliom (a component of Ocsigen), update the package lists, and install the dependencies of Eliom:
sudo apt-get update sudo apt-get install \ libev-dev libgdbm-dev libncurses5-dev libpcre3-dev \ libssl-dev libsqlite3-dev libcairo-ocaml-dev m4 \ opam camlp4-extra \ libgmp-dev
After that, use OPAM (the OCaml package manager) to install
opam init opam install eliom
Now that you have Eliom installed, you can create a new Eliom project.
Creating an Eliom project
To create a new Eliom project:
eliom-distillery -name helloworld -target-directory helloworld
This will create a directory named
helloworld that contains your Eliom project. This directory contains a file that has a
.eliom extension. This is where the source code of the web application goes.
Writing a Hello World application
Replace the contents of the
helloworld.eliom file with the following:
let hello_world = Eliom_content.Html.D.( Eliom_registration.Html.create ~path:(Eliom_service.Path [""]) ~meth:(Eliom_service.Get Eliom_parameter.unit) (fun () () -> Lwt.return (html (head (title (pcdata "Hello World")) ) (body [h1 [pcdata "Hello World."]]))))
After that, run
make test.byte, open your web browser and navigate to
http://localhost:8080. You should see a page that containing 'Hello World.'.
I hope that was good enough of an example to get you started on this web framework. Ocsigen and Eliom are capable of so much more than the conventional back-end web frameworks out there. I urge you to read the Ocsigen documentation and its tutorials.