From: Christophe TROESTLER <Christophe.Troestler@umh.ac.be>
To: christos.jonathan.hayward@gmail.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] "Hello web" please
Date: Mon, 10 Jul 2006 17:48:00 +0200 (CEST) [thread overview]
Message-ID: <20060710.174800.180966261.Christophe.Troestler@umh.ac.be> (raw)
In-Reply-To: <fdc31b650607100802g570e96beo1395bcb244353bf2@mail.gmail.com>
[-- Attachment #1: Type: Text/Plain, Size: 745 bytes --]
On Mon, 10 Jul 2006, "Jonathan Hayward http://JonathansCorner.com" <christos.jonathan.hayward@gmail.com> wrote:
>
> What should the shebang line say?
> #!/usr/local/bin/ocaml
#!/usr/local/bin/ocamlrun ocaml
You also need to load the necessary libraries:
#load "pcre.cma";;
#load "unix.cma";;
...
#load "netcgi.cma";;
(see attached file).
> when I run it from within apache I get an internal server error. (A
> copy of the command line output follows the script).
Do you run is as CGI ? Also beware that the newer Netcgi module is
not in the tarball you mentioned. Get the SVN version if you want to
use it (I am not sure the build system already compiles it as its
insersion is very recent but I can fix that).
Cheers,
ChriS
[-- Attachment #2: script.ml --]
[-- Type: Text/Plain, Size: 1463 bytes --]
#!/usr/bin/ocamlrun ocaml
(* Change the directories as needed for your system. *)
#directory "+pcre";;
#load "pcre.cma";;
#load "unix.cma";;
#directory "+netstring";;
#load "netstring.cma";;
#directory "/path/to/netcgi/";;
#load "netcgi.cma";;
open Netcgi
let text = Netencoding.Html.encode_from_latin1
(* This function encodes "<", ">", "&", double quotes, and Latin 1
characters as character entities. E.g. text "<" = "<", and
text "ä" = "ä" *)
(* Normally you would use a template system instead of this *)
let html_page (cgi:cgi) title html =
let out = cgi#out_channel#output_string in
out "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \
\" http://www.w3.org/TR/REC-html40/strict.dtd\">\n";
out ("<html>\n<head><title>" ^ text title ^"</title></head>
<body>\n");
out html;
out "</body>\n</html>"
let main (cgi:cgi) =
cgi#set_header
~cache:`No_cache
~content_type:"text/html; charset=\"iso-8859-1\""
();
let foo = cgi#argument_value "foo" in
let html = match foo with
| "1" -> "Yes"
| "0" -> "No"
| _ -> "Undefined" in
html_page cgi foo html
(* You can buffer or not the output. If buffered you can rollback
(useful in case of error). You can replace Netcgi_cgi.run by
another connector entry point (FCGI, SCGI, AJP, Apache mod). *)
let () =
let buffered _ ch = new Netchannels.buffered_trans_channel ch in
Netcgi_cgi.run ~output_type:(`Transactional buffered) main
next prev parent reply other threads:[~2006-07-10 15:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-08 15:05 Jonathan Hayward http://JonathansCorner.com
2006-07-08 20:47 ` [Caml-list] " Christophe TROESTLER
2006-07-10 15:02 ` Jonathan Hayward http://JonathansCorner.com
2006-07-10 15:48 ` Christophe TROESTLER [this message]
2006-07-11 14:23 ` Jonathan Hayward http://JonathansCorner.com
2006-07-11 14:33 ` Maxence Guesdon
2006-07-11 14:42 ` Christophe TROESTLER
2006-07-11 17:40 ` Jonathan Hayward http://JonathansCorner.com
2006-07-11 18:14 ` Christophe TROESTLER
2006-07-11 20:35 ` Jonathan Hayward http://JonathansCorner.com
2006-07-12 11:20 ` Jonathan Roewen
2006-07-10 15:51 ` Jonathan Roewen
2006-07-10 14:49 ` Jonathan Hayward http://JonathansCorner.com
2006-07-10 15:14 ` [Caml-list] " Christophe TROESTLER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060710.174800.180966261.Christophe.Troestler@umh.ac.be \
--to=christophe.troestler@umh.ac.be \
--cc=caml-list@yquem.inria.fr \
--cc=christos.jonathan.hayward@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox