From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 3D301BC57 for ; Tue, 21 Sep 2010 21:46:20 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgkCAJOomEzU4366kGdsb2JhbACDHJ8OFQEBAQEJCQwHEQMfskCSOQKBIIMscwSGcoZE X-IronPort-AV: E=Sophos;i="4.56,401,1280700000"; d="scan'208";a="70289840" Received: from moutng.kundenserver.de ([212.227.126.186]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 Sep 2010 21:46:19 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-221-128.pools.arcor-ip.net [94.219.221.128]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Mh8wH-1PB9KO24Dh-00Mx1p; Tue, 21 Sep 2010 21:46:05 +0200 Received: from [192.168.0.29] (dslb-084-058-040-212.pools.arcor-ip.net [84.58.40.212]) by office1.lan.sumadev.de (Postfix) with ESMTPA id 03C315F702; Tue, 21 Sep 2010 21:46:04 +0200 (CEST) Subject: Re: [Caml-list] web server interface for Ocaml ( like rack, wsgi, ...)? From: Gerd Stolpmann To: Richard Jones Cc: ben kuin , caml-list@inria.fr In-Reply-To: <20100921192048.GA25700@annexia.org> References: <20100919103258.GA14826@annexia.org> <20100921192048.GA25700@annexia.org> Content-Type: text/plain; charset="UTF-8" Date: Tue, 21 Sep 2010 21:46:03 +0200 Message-ID: <1285098363.20388.57.camel@thinkpad> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:5ro95RQb7GQfgatwcwlQjuA08GBfCMrrU+ATYw+2Ad+ wO4LXg0PKpbx7xsVvVhSUhMI32dGZBcnQ3wK/8C6uYC2LpL7Mx va6KIOpxPDFIa+mbX8oytXr3nBgIwo7a6hLvfwBkJ3NOgyDyrA 8PVDRVFGXVUwI2NJ8Ijzq+YwC+hFv6R39qn3LFwwTGk4p1IfoE 3GoKgryj5ueGMrmhYJG2A== X-Spam: no; 0.00; ocaml:01 gerd:01 stolpmann:01 0200,:01 ocamlnet:01 compilation:01 ocaml:01 wikipedia:01 lambda:01 usr:01 ocamlrun:01 ocamlnet:01 gerd:01 ocamlrun:01 topfind:01 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 ------------------------------------------------------------