Plack (software)
Encyclopedia
Plack is a set of tools for running Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

-based Web application
Web application
A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...

s and frameworks
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...

 compatible with the PSGI
PSGI
PSGI or Perl Web Server Gateway Interface is an interface between Web servers and Perl-based Web applications and frameworks that allows writing portable applications that can be run as standalone servers or using CGI, FastCGI, mod_perl, et al...

 specification.

Plack was inspired by Rack
Rack (web server interface)
Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between into a single method call.Rack is...

 for Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

 and Paste
Python Paste
Python Paste, often simply called paste, is a set of utilities for web development in Python. Paste has been described as "a framework for web frameworks".-Python Paste:...

 for Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

.

Plackup is a command-line tool for running the PSGI applications,

Supported backends

Plack supports the following server backends:
  • CGI
    Common Gateway Interface
    The Common Gateway Interface is a standard method for web servers software to delegate the generation of web pages to executable files...

  • SCGI
    Simple Common Gateway Interface
    The Simple Common Gateway Interface is a protocol for applications to interface with HTTP servers, as an alternative to the CGI protocol...

  • FastCGI
    FastCGI
    FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface ; FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page...

  • mod perl
    Mod perl
    mod_perl is an optional module for the Apache HTTP server. It embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request...

     under Apache
    Apache HTTP Server
    The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

     1.3 and 2.0
  • Standalone HTTP server included in Plack
  • HTTP::Server::Simple
  • Corona
  • Starman
  • Twiggy
  • AnyEvent::HTTPD
  • AnyEvent::ReverseHTTP

Examples

Using the default standalone HTTP server:

$ plackup app.psgi
HTTP::Server::PSGI: Accepting connections at http://0:5000/

Running as a FastCGI daemon
Daemon (computer software)
In Unix and other multitasking computer operating systems, a daemon is a computer program that runs as a background process, rather than being under the direct control of an interactive user...

 listening on a Unix socket, ready to be used by any Web server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

 with FastCGI support:

$ plackup -s FCGI --listen /tmp/fcgi.sock app.psgi
FastCGI: manager (pid 3336): initialized
FastCGI: manager (pid 3336): server (pid 3337) started
FastCGI: server (pid 3337): initialized

A working Hello world application run as a one-liner
One-liner program
A one-liner is textual input to the command-line of an operating system shell that performs some function in just one line of input.The one liner can be# An expression written in the language of the shell....

:

$ plackup -e 'sub { [200, ["Content-Type" => "text/plain"], ["Hello, world!"]] }'
HTTP::Server::PSGI: Accepting connections at http://0:5000/

The command above starts an HTTP server listening on port
TCP and UDP port
In computer networking, a port is an application-specific or process-specific software construct serving as a communications endpoint in a computer's host operating system. A port is associated with an IP address of the host, as well as the type of protocol used for communication...

 5000 of every local interface (IP address
IP address
An Internet Protocol address is a numerical label assigned to each device participating in a computer network that uses the Internet Protocol for communication. An IP address serves two principal functions: host or network interface identification and location addressing...

) and returns this 200 OK response to every HTTP request:

HTTP/1.0 200 OK
Date: Fri, 19 Mar 2010 23:34:10 GMT
Server: HTTP::Server::PSGI
Content-Type: text/plain
Content-Length: 13

Hello, world!

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK