Updated Pharo HTTP Server Single Command Line Demo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Updated Pharo HTTP Server Single Command Line Demo

Sven Van Caekenberghe
I updated my Pharo HTTP Server OneCommandLine Demo for 1.4

  http://forum.world.st/Pharo-Core-HTTP-Server-OneCommandLine-Demo-td3702218.html

How easy and how fast can you download, install and start an complete Pharo based HTTP Server on a bare Linux machine ?

It just takes One Single Command Line:

        $ curl http://zn.stfx.eu/zn/pharo-server.sh | bash

In well under a minute, you can browse http://localhost:1701 and all this with less than 20Mb being downloaded.

Enjoy,


Sven


--
Sven Van Caekenberghe
http://stfx.eu
Smalltalk is the Red Pill





Reply | Threaded
Open this post in threaded view
|

Re: Updated Pharo HTTP Server Single Command Line Demo

Damien Cassou
Hi Sven,

On Mon, Feb 20, 2012 at 3:08 PM, Sven Van Caekenberghe <[hidden email]> wrote:
> In well under a minute, you can browse http://localhost:1701 and all this with less than 20Mb being downloaded.

I don't get it. What is this server serving exactly? Where are the served files?

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry

Reply | Threaded
Open this post in threaded view
|

Re: Updated Pharo HTTP Server Single Command Line Demo

Sven Van Caekenberghe
Damien,

On 20 Feb 2012, at 16:00, Damien Cassou wrote:

> Hi Sven,
>
> On Mon, Feb 20, 2012 at 3:08 PM, Sven Van Caekenberghe <[hidden email]> wrote:
>> In well under a minute, you can browse http://localhost:1701 and all this with less than 20Mb being downloaded.
>
> I don't get it. What is this server serving exactly? Where are the served files?
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Lambdas are relegated to relative obscurity until Java makes them
> popular by not having them." James Iry

Glad you asked ;-)

It is an HTTP server, not necessarily a static file server (but it could be an elementary one, given proper configuration, see ZnStaticFileServerDelegate).

What you see, is what ZnServer exposes by default, as implemented by ZnDefaultServerDelegate, which is just some friendly welcome page (like when you install an unconfigured Apache) combined with somewhat hidden test functionality. From the class comment:

---

I am ZnDefaultServerDelegate.
I function as a delegate for ZnServer, implementing #handleRequest:

I implement responses to the following prefixes:

/echo - an echo text of request information for debugging purposes
/dw-bench - a dynamic html page for benchmarking purposes
/unicode - a unicode test page
/random - a random string (/random/32 for a specific size)
/bytes - bytes according to a pattern (/bytes/32 for a specific size)
/favicon.ico - a Zn favicon
/status - a server status page
/help - lists all page prefixes
/ - an html welcome page

Without any matches, I respond with a page not found.

Part of Zinc HTTP Components.

---

Sven

PS:

Other interesting delegates are ZnDispatcherDelegate as well as ZnMonticelloServerDelegate.
 
The pages at http://zn.stfx.eu and in particular http://zn.stfx.eu/help serve this live, with the following config:

ZnServer startDefaultOn: 8080.
!
| staticFileServer |
(staticFileServer := ZnStaticFileServerDelegate new)
        prefixFromString: 'zn';
        directory: (FileDirectory on: '/home/ubuntu/zn').
ZnServer default delegate prefixMap
        at: 'zn'
        put: [ :request | staticFileServer handleRequest: request ];
        at: 'redirect-to-zn'
        put: [ :request | ZnResponse redirect: '/zn/index.html' ];
        at: '/'
        put: 'redirect-to-zn'.