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


let main (cgi : Netcgi.std_activation) =
  try
6
7
8
    cgi # set_header
      ~content_type:"text/html; charset=\"iso-8859-1\""
      ();
9
    let src = cgi # argument_value "prog" in
10
11

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

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