webiface.ml 1.1 KB
Newer Older
1
2
3
4
5
6
open Netcgi


let main (cgi : Netcgi.std_activation) =
  try
    cgi # set_header ();
7
    let src = cgi # argument_value "prog" in
8
9

    let ppf = Format.str_formatter
10
11
12
13
14
    and input = Stream.of_string src in
    Location.set_source (`String src);
    Location.set_viewport `Html;
    Load_xml.set_auth false;
    
15
    Cduce.run ppf input;
16
17
18
19
20
21
22
23
24
    let res = Format.flush_str_formatter () in

    cgi # output # output_string ("\
<html>
<head>
  <title>CDuce online prototype</title>
</head>
<body>
  <h1>CDuce online prototype</h1>
25
<pre>" ^ res ^ "</pre>
26

27
<form method=post>
28
29
 <textarea name=prog cols=80 rows=25></textarea>
 <input type=submit>
30
31
32
33
34
35
36
37
38
39
</form>
</body>
</html>
");
    cgi # output # commit_work()
  with
      exn ->
	cgi # output # rollback_work();
	cgi # set_header ~status:`Internal_server_error ();
	cgi # output # output_string "<h1>Internal software error!</h1>";
40
	cgi # output # output_string (Printexc.to_string exn);
41
42
43
44
45
46
47
48
	cgi # output # commit_work()

let () =
  let operating_type = Netcgi.buffered_transactional_optype in
  let cgi = new Netcgi.std_activation ~operating_type () in
  main cgi;
  cgi # finalize ()