How to make a "hello world" in Ocsigen?

Here it is! The famous "Hello World" for a client/server Eliom application:

open Eliom_content
open Html5.D
open Eliom_parameter

module Example =
  Eliom_registration.App
    (struct
      let application_name = "example"
     end)

let main =
  Eliom_service.service
    ~path:[]
    ~get_params:unit
    ()

let _ =

  Example.register
    ~service:main
    (fun () () ->
      Lwt.return
	(html
	   (head (title (pcdata "Hello World of Ocsigen")) [])
	   (body [h1 [pcdata "Hello World!"];
		  p [pcdata "Welcome to my first Ocsigen website."]])))

Now I guess you want to actually understand this code. You can:

Download full code (recommended)

Links

◄ Back to the Quick Howto's