caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* web server interface for Ocaml ( like rack, wsgi, ...)?
@ 2010-09-16 11:05 ben kuin
  2010-09-16 16:04 ` [Caml-list] " Michael Ekstrand
  2010-09-16 17:29 ` Jake Donham
  0 siblings, 2 replies; 16+ messages in thread
From: ben kuin @ 2010-09-16 11:05 UTC (permalink / raw)
  To: caml-list

hi
Is there a web server interface / adapter for ocaml that abstracts
your application from the various web server implementations?
What is your prefered way to write a small web app for example a to-do list?
thanks
ben


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 11:05 web server interface for Ocaml ( like rack, wsgi, ...)? ben kuin
@ 2010-09-16 16:04 ` Michael Ekstrand
  2010-09-16 17:29 ` Jake Donham
  1 sibling, 0 replies; 16+ messages in thread
From: Michael Ekstrand @ 2010-09-16 16:04 UTC (permalink / raw)
  To: ben kuin; +Cc: caml-list

On Thu, 2010-09-16 at 13:05 +0200, ben kuin wrote:
> Is there a web server interface / adapter for ocaml that abstracts
> your application from the various web server implementations?
> What is your prefered way to write a small web app for example a to-do list?

There are two good options:
      * Ocsigen <http://ocsigen.org>, a web server and application
        framework in OCaml.  At this point, you must use its web server
        (which you could put behind Apache or whatever with a reverse
        proxy).  The setup would look like a lot of Rails deployments.
        I currently use Ocsigen alone on my web site.
      * OCamlNet <http://projects.camlcity.org/projects/ocamlnet.html>
        provides a CGI API with FastCGI and AJP adapters for building
        web applications.  You can run that behind most web servers.

- Michael

-- 
Web/blog: http://elehack.net/michael
Jabber/Google Talk: this e-mail address
Twitter: http://twitter.com/elehack
mouse, n: a device for pointing at the xterm in which you want to type


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 11:05 web server interface for Ocaml ( like rack, wsgi, ...)? ben kuin
  2010-09-16 16:04 ` [Caml-list] " Michael Ekstrand
@ 2010-09-16 17:29 ` Jake Donham
  2010-09-16 19:00   ` Paolo Donadeo
  2010-09-19 10:32   ` Richard Jones
  1 sibling, 2 replies; 16+ messages in thread
From: Jake Donham @ 2010-09-16 17:29 UTC (permalink / raw)
  To: ben kuin; +Cc: caml-list

On Thu, Sep 16, 2010 at 4:05 AM, ben kuin <benkuin@gmail.com> wrote:
> Is there a web server interface / adapter for ocaml that abstracts
> your application from the various web server implementations?

There is no OCaml equivalent to rack / wsgi. It would be nice to have
something like this; the existing web frameworks (e.g. Ocamlnet and
Ocsigen as another poster mentioned) implement the whole stack, but it
would be nice to be able to mix and match (e.g. run Ocsigen's Eliom
applications in Ocamlnet's Netplex server). Part of the difficulty is
that there are different approaches to concurrency/asynchrony (Lwt for
Ocsigen, Equeue for netplex). My impression is that rack / wsgi punt
on this issue, and assume threading. But an OCaml equivalent could
possibly offer both a concurrent/asynchronous and a direct-style
interface.

Jake


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 17:29 ` Jake Donham
@ 2010-09-16 19:00   ` Paolo Donadeo
  2010-09-16 22:04     ` Dario Teixeira
  2010-09-19 10:32   ` Richard Jones
  1 sibling, 1 reply; 16+ messages in thread
From: Paolo Donadeo @ 2010-09-16 19:00 UTC (permalink / raw)
  To: OCaml mailing list

> It would be nice to have something like this; the existing web
> frameworks (e.g. Ocamlnet and Ocsigen as another poster mentioned)
> implement the whole stack, but it would be nice to be able to mix
> and match (e.g. run Ocsigen's Eliom applications in Ocamlnet's
> Netplex server).

Ah! So I'm not the only one to think that this could be a killer
application and a huge driver for the diffusion of OCaml.
Unfortunately the Ocsigen team doesn't consider a FastCGI connector a
priority of any kind, and of course, Gerd doesn't have interest and
time in porting Eliom on Ocamlnet. It's a royal pity!


> My impression is that rack / wsgi punt on this issue, and assume
> threading. But an OCaml equivalent could possibly offer both a
> concurrent/asynchronous and a direct-style interface.

I don't know wsgi, but FastCGI is completely agnostic with regarding
to the concurrency model. A FastCGI server is an application listening
on a socket (Unix or Internet), and that's all.

My dream is *really* Eliom over Ocamlnet.


-- 
Paolo ⠠⠵


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 19:00   ` Paolo Donadeo
@ 2010-09-16 22:04     ` Dario Teixeira
  2010-09-16 22:27       ` Michael Ekstrand
  2010-09-17  7:59       ` Paolo Donadeo
  0 siblings, 2 replies; 16+ messages in thread
From: Dario Teixeira @ 2010-09-16 22:04 UTC (permalink / raw)
  To: OCaml mailing list, Paolo Donadeo

Hi,

> My dream is *really* Eliom over Ocamlnet.

Could you expand on the reasoning a little?  I mean, what is for you
the advantage of running Eliom over Ocamlnet as opposed to over the
Ocsigen server?

Cheers,
Dario Teixeira






^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 22:04     ` Dario Teixeira
@ 2010-09-16 22:27       ` Michael Ekstrand
  2010-09-16 23:55         ` Vincent Balat
  2010-09-17  8:03         ` Paolo Donadeo
  2010-09-17  7:59       ` Paolo Donadeo
  1 sibling, 2 replies; 16+ messages in thread
From: Michael Ekstrand @ 2010-09-16 22:27 UTC (permalink / raw)
  To: OCaml mailing list

On Thu, 2010-09-16 at 15:04 -0700, Dario Teixeira wrote:
> Could you expand on the reasoning a little?  I mean, what is for you
> the advantage of running Eliom over Ocamlnet as opposed to over the
> Ocsigen server?

Running Eliom over OCamlNet lets it integrate a bit more closely with a
third-party web server via FastCGI.  Standard functions such as absolute
URL construction and SSL checking that depend on the host, port, and
connection type have a knack for breaking when run behind a reverse
proxy.  So, if you're trying to integrate an Eliom web service into a
larger site running Apache/nginx/lighttpd/whatever, FastCGI can be a
huge benefit.

OTOH, if Ocsigen had a FastCGI extension, that could alleviate the need
for another web server in some cases.

- Michael

-- 
Web/blog: http://elehack.net/michael
Jabber/Google Talk: this e-mail address
Twitter: http://twitter.com/elehack
mouse, n: a device for pointing at the xterm in which you want to type


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 22:27       ` Michael Ekstrand
@ 2010-09-16 23:55         ` Vincent Balat
  2010-09-17  8:08           ` Paolo Donadeo
  2010-09-17  8:03         ` Paolo Donadeo
  1 sibling, 1 reply; 16+ messages in thread
From: Vincent Balat @ 2010-09-16 23:55 UTC (permalink / raw)
  To: caml-list; +Cc: Michael Ekstrand

[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]

> Running Eliom over OCamlNet lets it integrate a bit more closely with a
> third-party web server via FastCGI.  Standard functions such as absolute
> URL construction and SSL checking that depend on the host, port, and
> connection type have a knack for breaking when run behind a reverse
> proxy.

That is not really true for Eliom, as the programmer never writes the URLs 
himself and Eliom does this cleanly with the right information (actually all 
URLs are relative, except for switching from http to https or redirections. 
And in that case the host and port are taken from the config file).

About Eliom, Ocsigen server and fastCGI:

 - Writing a version of Eliom working with fastCGI is theoretically possible, 
even if it is probably a huge work. I recommand to wait for version 2 of Eliom 
(in a few months) as there are many new features. But once again I'm not 
convinced at all that it is interesting.

 - Writing a fastCGI extension for Ocsigen server should be quite easy to do 
for someone used to LWT programming. Extending Ocsigen server is very simple. 
That is not in our plans for the next months, as we are currently 
concentrating a lot on Eliom 2. A contribution would be welcome. We can also 
probably take in charge the development if someone wants to pay for it.

Vincent

[-- Attachment #2: Type: text/html, Size: 4034 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 22:04     ` Dario Teixeira
  2010-09-16 22:27       ` Michael Ekstrand
@ 2010-09-17  7:59       ` Paolo Donadeo
  2010-09-17  8:57         ` Stéphane Glondu
  1 sibling, 1 reply; 16+ messages in thread
From: Paolo Donadeo @ 2010-09-17  7:59 UTC (permalink / raw)
  To: OCaml mailing list

On Fri, Sep 17, 2010 at 00:04, Dario Teixeira wrote:

> Could you expand on the reasoning a little?  I mean, what is for you
> the advantage of running Eliom over Ocamlnet as opposed to over the
> Ocsigen server?

>From my point of view the problem with Ocsigen is that it requires you
to install an HTTP server. In the real world the programmer, or even
the project leader, don't have this freedom of choice, because there
are system constraints imposed by others. You are often asked to
provide an application, along with detailed instruction for the
installation in a standard environment, where one (ore more) HTTP
servers have some standard connectors (WSGI, FastCGI, AJP, etc...)

I'm not complaining about the Ocsigen team, of course: they are
focused on other aspects than the deploy, and this is why Eliom is so
interesting and, on the other side, I should help them, but in this
moment I have no time for another project.


-- 
Paolo ⠠⠵


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 22:27       ` Michael Ekstrand
  2010-09-16 23:55         ` Vincent Balat
@ 2010-09-17  8:03         ` Paolo Donadeo
  1 sibling, 0 replies; 16+ messages in thread
From: Paolo Donadeo @ 2010-09-17  8:03 UTC (permalink / raw)
  To: Michael Ekstrand; +Cc: OCaml mailing list

On Fri, Sep 17, 2010 at 00:27, Michael Ekstrand wrote:
> OTOH, if Ocsigen had a FastCGI extension, that could alleviate the need
> for another web server in some cases.

Only if you have access to the server configuration. And I don't know
a single sysadmin that will replace Apache with Ocsigen.

"Ocsi-what? What is it? My system? Replace Apache? Forget it!"

:-)


-- 
Paolo ⠠⠵


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 23:55         ` Vincent Balat
@ 2010-09-17  8:08           ` Paolo Donadeo
  0 siblings, 0 replies; 16+ messages in thread
From: Paolo Donadeo @ 2010-09-17  8:08 UTC (permalink / raw)
  To: Vincent Balat; +Cc: caml-list

On Fri, Sep 17, 2010 at 01:55, Vincent Balat wrote:
> Writing a version of Eliom working with fastCGI is theoretically possible,
> even if it is probably a huge work.

I don't know the inner details of both Ocsigen and Ocamlnet, but
consider that Jake wrote lwt-equeue [1], I think this could help.


[1] http://github.com/jaked/lwt-equeue

-- 
Paolo ⠠⠵


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-17  7:59       ` Paolo Donadeo
@ 2010-09-17  8:57         ` Stéphane Glondu
  0 siblings, 0 replies; 16+ messages in thread
From: Stéphane Glondu @ 2010-09-17  8:57 UTC (permalink / raw)
  To: Paolo Donadeo; +Cc: OCaml mailing list

Le 17/09/2010 09:59, Paolo Donadeo a écrit :
>> Could you expand on the reasoning a little?  I mean, what is for you
>> the advantage of running Eliom over Ocamlnet as opposed to over the
>> Ocsigen server?
>
>> From my point of view the problem with Ocsigen is that it requires you
> to install an HTTP server. In the real world the programmer, or even
> the project leader, don't have this freedom of choice, because there
> are system constraints imposed by others. You are often asked to
> provide an application, along with detailed instruction for the
> installation in a standard environment, where one (ore more) HTTP
> servers have some standard connectors (WSGI, FastCGI, AJP, etc...)

Ocsigen can run with most other webservers via a reverse proxy. The 
Ocsigen process itself doesn't even need to have special privileges, and 
can be installed and run by a regular user. If you are allowed to use 
WSGI, FastCGI, AJP, etc., it shouldn't be more difficult to use Ocsigen. 
Process management might not be as handy, so you'll have to manage 
somehow the ocsigen process crashing / being killed, but there are other 
tools (e.g. monit) for that.

I'm not saying that WSGI, FastCGI, AJP, etc. support for Eliom has no 
benefit! But we can live (and we do) without it for now.

-- 
Stéphane


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-16 17:29 ` Jake Donham
  2010-09-16 19:00   ` Paolo Donadeo
@ 2010-09-19 10:32   ` Richard Jones
  2010-09-21  7:50     ` ben kuin
  1 sibling, 1 reply; 16+ messages in thread
From: Richard Jones @ 2010-09-19 10:32 UTC (permalink / raw)
  To: Jake Donham; +Cc: ben kuin, caml-list

On Thu, Sep 16, 2010 at 10:29:23AM -0700, Jake Donham wrote:
> On Thu, Sep 16, 2010 at 4:05 AM, ben kuin <benkuin@gmail.com> wrote:
> > Is there a web server interface / adapter for ocaml that abstracts
> > your application from the various web server implementations?
> 
> There is no OCaml equivalent to rack / wsgi. It would be nice to have
> something like this; the existing web frameworks (e.g. Ocamlnet and
> Ocsigen as another poster mentioned) implement the whole stack, but it
> would be nice to be able to mix and match (e.g. run Ocsigen's Eliom
> applications in Ocamlnet's Netplex server). Part of the difficulty is
> that there are different approaches to concurrency/asynchrony (Lwt for
> Ocsigen, Equeue for netplex). My impression is that rack / wsgi punt
> on this issue, and assume threading. But an OCaml equivalent could
> possibly offer both a concurrent/asynchronous and a direct-style
> interface.

Maybe I'm missing the point, but what's wrong with simply proxying the
HTTP connections through your favorite webserver to the backend
ocsigen/ocamlnet server?

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-19 10:32   ` Richard Jones
@ 2010-09-21  7:50     ` ben kuin
  2010-09-21 19:20       ` Richard Jones
  0 siblings, 1 reply; 16+ messages in thread
From: ben kuin @ 2010-09-21  7:50 UTC (permalink / raw)
  To: Richard Jones, caml-list

> 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
~~~~~~~~~~~~~~~~~~~~




On Sun, Sep 19, 2010 at 12:32 PM, Richard Jones <rich@annexia.org> wrote:
> On Thu, Sep 16, 2010 at 10:29:23AM -0700, Jake Donham wrote:
>> On Thu, Sep 16, 2010 at 4:05 AM, ben kuin <benkuin@gmail.com> wrote:
>> > Is there a web server interface / adapter for ocaml that abstracts
>> > your application from the various web server implementations?
>>
>> There is no OCaml equivalent to rack / wsgi. It would be nice to have
>> something like this; the existing web frameworks (e.g. Ocamlnet and
>> Ocsigen as another poster mentioned) implement the whole stack, but it
>> would be nice to be able to mix and match (e.g. run Ocsigen's Eliom
>> applications in Ocamlnet's Netplex server). Part of the difficulty is
>> that there are different approaches to concurrency/asynchrony (Lwt for
>> Ocsigen, Equeue for netplex). My impression is that rack / wsgi punt
>> on this issue, and assume threading. But an OCaml equivalent could
>> possibly offer both a concurrent/asynchronous and a direct-style
>> interface.
>
> Maybe I'm missing the point, but what's wrong with simply proxying the
> HTTP connections through your favorite webserver to the backend
> ocsigen/ocamlnet server?
>
> Rich.
>
> --
> Richard Jones
> Red Hat
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-21  7:50     ` ben kuin
@ 2010-09-21 19:20       ` Richard Jones
  2010-09-21 19:46         ` Gerd Stolpmann
  2010-09-21 19:58         ` Martin Jambon
  0 siblings, 2 replies; 16+ messages in thread
From: Richard Jones @ 2010-09-21 19:20 UTC (permalink / raw)
  To: ben kuin; +Cc: caml-list

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??

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-21 19:20       ` Richard Jones
@ 2010-09-21 19:46         ` Gerd Stolpmann
  2010-09-21 19:58         ` Martin Jambon
  1 sibling, 0 replies; 16+ messages in thread
From: Gerd Stolpmann @ 2010-09-21 19:46 UTC (permalink / raw)
  To: Richard Jones; +Cc: ben kuin, caml-list

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
------------------------------------------------------------


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)?
  2010-09-21 19:20       ` Richard Jones
  2010-09-21 19:46         ` Gerd Stolpmann
@ 2010-09-21 19:58         ` Martin Jambon
  1 sibling, 0 replies; 16+ messages in thread
From: Martin Jambon @ 2010-09-21 19:58 UTC (permalink / raw)
  To: Richard Jones; +Cc: ben kuin, caml-list

Richard Jones wrote:
> 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??

I am pretty sure this is possible to do with Ocamlnet (netcgi2) although I
haven't done it in a while.

My recommendation would be to use ocamlscript, which relies on ocamlfind to
load libraries and compiles the executables only when needed, based on timestamps.

http://martin.jambon.free.fr/ocamlscript.html

You can try this:

#! /usr/bin/env ocamlscript
Ocaml.packs := [ "netcgi2" ]
--

let handle_request (cgi : Netcgi.cgi) =
  cgi # set_header ~content_type:"text/plain" ();
  cgi # output # output_string "Hello!\n";
  cgi # output # commit_work ()

let () =
  if Netcgi_cgi.is_cgi () then
    Netcgi_cgi.run handle_request
  else
    Netcgi_test.run handle_request


I don't know if it works when called from apache.  There might be permission
issues.  In general I think it's a bad idea to let the webserver do the
precious program analysis (compilation) in a live installation, but it's free
to try.  Ocamlscript also has an option to just compile the script and takes
care of cleaning up the compilation by-products.


Martin

-- 
http://mjambon.com/


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-09-21 19:58 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-16 11:05 web server interface for Ocaml ( like rack, wsgi, ...)? ben kuin
2010-09-16 16:04 ` [Caml-list] " Michael Ekstrand
2010-09-16 17:29 ` Jake Donham
2010-09-16 19:00   ` Paolo Donadeo
2010-09-16 22:04     ` Dario Teixeira
2010-09-16 22:27       ` Michael Ekstrand
2010-09-16 23:55         ` Vincent Balat
2010-09-17  8:08           ` Paolo Donadeo
2010-09-17  8:03         ` Paolo Donadeo
2010-09-17  7:59       ` Paolo Donadeo
2010-09-17  8:57         ` Stéphane Glondu
2010-09-19 10:32   ` Richard Jones
2010-09-21  7:50     ` ben kuin
2010-09-21 19:20       ` Richard Jones
2010-09-21 19:46         ` Gerd Stolpmann
2010-09-21 19:58         ` Martin Jambon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).