Xt templating language (OCaml server) (http://chris.pacejo.net/programs/xt)

root / xtPgHTTP.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
let _ =
	if Array.length Sys.argv > 1 && Sys.argv.(1) = "--help" then begin
		Printf.printf "Usage: %s [[IP] port] [document_root]\n" Sys.argv.(0);
		Printf.printf "Defaults: %s 127.0.0.1 8080 %s\n" Sys.argv.(0) Filename.current_dir_name;
		print_endline "WARNING: You should NOT run this server on a public IP/port!";
		exit 1
	end;
	let host =
		if Array.length Sys.argv > 3 then Some (Unix.inet_addr_of_string Sys.argv.(1))
		else None
	and port =
		if Array.length Sys.argv > 3 then Some (int_of_string Sys.argv.(2))
		else if Array.length Sys.argv > 1 then Some (int_of_string Sys.argv.(1))
		else None
	and document_root =
		if Array.length Sys.argv > 2 then Some Sys.argv.(Array.length Sys.argv - 1)
		else None in
	let module M = CGI.HTTP(XtPg.Handler) in
	M.main ?host ?port ?document_root ()