Browse thread
web server interface for Ocaml ( like rack, wsgi, ...)?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Gerd Stolpmann <info@g...> |
| Subject: | Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)? |
Am Dienstag, den 21.09.2010, 20:20 +0100 schrieb Richard Jones:
> On Tue, Sep 21, 2010 at 09:50:36AM +0200, ben kuin wrote:
> > > what's wrong with simply proxying the HTTP connections through your favorite webserver to the backend ocsigen/ocamlnet server?
> >
> > Nothing per se. I've tried so set something up with ocsigen, but I had
> > to give up. There seems to be a certain philosophy behind it how you
> > should writing web apps.
> >
> > But I just wanted to do something:
> > - small ( one page app )
> > - quick and dirty ( no big setup upfront, no compilation)
> > - deployment, by dropping a (ocaml script) into a webroot, not matter
> > what webserver is running
> > - permissive license ( mit, ...)
>
> >
> > ~~~~ from wikipedia ~~~~
> > require 'rack'
> > app = Rack::Builder.app do
> > lambda do |env|
> > body = "Hello, World!"
> > [200, {"Content-Type" => "text/plain", "Content-Length" =>
> > body.length.to_s}, [body]]
> > end
> > end
>
> This ought to work, and it's pretty simple ...
>
> -----
> #!/usr/bin/ocamlrun ocaml
> print_string "\
> Content-Type: text/plain
>
> Hello, World!"
> -----
>
> 'course the problem is you'll be wanting to parse parameters, cookies
> and the rest of it, and there it does get a little bit more
> complicated.
>
> I'm fairly sure ocamlnet can write standalone scripts like that? Gerd??
#! /opt/godi-3.11/bin/ocamlrun /opt/godi-3.11/bin/ocaml
#use "topfind";;
#require "netcgi2";;
open Netcgi
let () =
Netcgi_cgi.run
~output_type:(`Direct "")
(fun cgi ->
let body = "Hello, World!" in
cgi # set_header
~content_type:"text/plain"
~content_length:(String.length body)
();
cgi # out_channel # output_string body;
cgi # out_channel # commit_work()
)
Gerd
--
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany
gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de
Phone: +49-6151-153855 Fax: +49-6151-997714
------------------------------------------------------------