| 4 |
let main (cgi : Netcgi.std_activation) = |
let main (cgi : Netcgi.std_activation) = |
| 5 |
try |
try |
| 6 |
cgi # set_header (); |
cgi # set_header (); |
| 7 |
let cmd = cgi # argument_value "cmd" in |
let src = cgi # argument_value "prog" in |
| 8 |
|
|
|
Location.set_source (`String cmd); |
|
| 9 |
let ppf = Format.str_formatter |
let ppf = Format.str_formatter |
| 10 |
and input = Stream.of_string cmd in |
and input = Stream.of_string src in |
| 11 |
Cduce.run ppf input; |
Location.set_source (`String src); |
| 12 |
|
Location.set_viewport `Html; |
| 13 |
|
Location.set_output ppf; |
| 14 |
|
Load_xml.set_auth false; |
| 15 |
|
|
| 16 |
|
Cduce.run (Location.protect ppf) input; |
| 17 |
let res = Format.flush_str_formatter () in |
let res = Format.flush_str_formatter () in |
| 18 |
|
|
| 19 |
cgi # output # output_string ("\ |
cgi # output # output_string ("\ |
| 23 |
</head> |
</head> |
| 24 |
<body> |
<body> |
| 25 |
<h1>CDuce online prototype</h1> |
<h1>CDuce online prototype</h1> |
| 26 |
Command == [" ^ cmd ^ "]<br> |
<pre>" ^ res ^ "</pre> |
|
Result:<pre>" ^ res ^ "</pre> |
|
| 27 |
|
|
| 28 |
<form method=get> |
<form method=get> |
| 29 |
<input type=text name=cmd length=30> |
<textarea name=prog cols=80 rows=25></textarea> |
| 30 |
|
<input type=submit> |
| 31 |
</form> |
</form> |
| 32 |
</body> |
</body> |
| 33 |
</html> |
</html> |
| 38 |
cgi # output # rollback_work(); |
cgi # output # rollback_work(); |
| 39 |
cgi # set_header ~status:`Internal_server_error (); |
cgi # set_header ~status:`Internal_server_error (); |
| 40 |
cgi # output # output_string "<h1>Internal software error!</h1>"; |
cgi # output # output_string "<h1>Internal software error!</h1>"; |
| 41 |
|
cgi # output # output_string (Printexc.to_string exn); |
| 42 |
cgi # output # commit_work() |
cgi # output # commit_work() |
| 43 |
|
|
| 44 |
let () = |
let () = |