webiface.ml 1.14 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
15
16
    and input = Stream.of_string src in
    Location.set_source (`String src);
    Location.set_viewport `Html;
    Location.set_output ppf;
    Load_xml.set_auth false;
    
    Cduce.run (Location.protect ppf) input;
17
18
19
20
21
22
23
24
25
    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>
26
<pre>" ^ res ^ "</pre>
27
28

<form method=get>
29
30
 <textarea name=prog cols=80 rows=25></textarea>
 <input type=submit>
31
32
33
34
35
36
37
38
39
40
</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>";
41
	cgi # output # output_string (Printexc.to_string exn);
42
43
44
45
46
47
48
49
	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 ()