
Plack is a
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
web application programming framework inspired by
Rack for
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
and
WSGI for
Python,
and it is the project behind the
PSGI specification used by other frameworks such as
Catalyst
Catalysis () is the increase in rate of a chemical reaction due to an added substance known as a catalyst (). Catalysts are not consumed by the reaction and remain unchanged after it. If the reaction is rapid and the catalyst recycles quick ...
and
Dancer
Dance is an The arts, art form, consisting of sequences of body movements with aesthetic and often Symbol, symbolic value, either improvised or purposefully selected. Dance can be categorized and described by its choreography, by its repertoir ...
.
Plack allows for testing of Perl web applications without a live web server.
Plackup is a
command line utility to run PSGI applications from the command line.
PSGI
PSGI or Perl Web Server Gateway Interface is an
interface between
web server
A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
s and
web application
A web application (or web app) is application software that is created with web technologies and runs via a web browser. Web applications emerged during the late 1990s and allowed for the server to dynamically build a response to the request, ...
s and
frameworks written in the
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
programming language that allows writing portable applications that can be run as standalone servers or using
CGI,
FastCGI
FastCGI is a binary protocol for interfacing interactive programs with a web server. It is a variation on the earlier Common Gateway Interface (CGI). FastCGI's main aim is to reduce the overhead related to interfacing between web server and CGI pr ...
,
mod_perl, et al.
It is inspired by the
Web Server Gateway Interface for
Python,
Rack for
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
and
JSGI for
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
. A PSGI application is a Perl
subroutine
In computer programming, a function (also procedure, method, subroutine, routine, or subprogram) is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times.
Callable units provide a ...
that accepts arguments as a single
hash
Hash, hashes, hash mark, or hashing may refer to:
Substances
* Hash (food), a coarse mixture of ingredients, often based on minced meat
* Hash (stew), a pork and onion-based gravy found in South Carolina
* Hash, a nickname for hashish, a canna ...
reference and returns a reference to an
array of three elements: an
HTTP status code, a reference to an array of
HTTP header
HTTP header fields are a list of strings sent and received by both the client program and server on every HTTP request and response. These headers are usually invisible to the end-user and are only processed or logged by the server and client ...
s and a reference to an array of HTTP body lines (usually a generated
HTML
Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets ( ...
document) or a
filehandle-like
object
Object may refer to:
General meanings
* Object (philosophy), a thing, being, or concept
** Object (abstract), an object which does not exist at any particular time or place
** Physical object, an identifiable collection of matter
* Goal, an a ...
.
Supported backends
Plack::Handler modules on CPAN
/ref> Plack supports the following server backends:
* CGI
* SCGI
* FastCGI
FastCGI is a binary protocol for interfacing interactive programs with a web server. It is a variation on the earlier Common Gateway Interface (CGI). FastCGI's main aim is to reduce the overhead related to interfacing between web server and CGI pr ...
* mod_perl under Apache
The Apache ( ) are several Southern Athabaskan language-speaking peoples of the Southwestern United States, Southwest, the Southern Plains and Northern Mexico. They are linguistically related to the Navajo. They migrated from the Athabascan ho ...
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
A demon is a malevolent supernatural being, evil spirit or fiend in religion, occultism, literature, fiction, mythology and folklore.
Demon, daemon or dæmon may also refer to:
Entertainment Fictional entities
* Daemon (G.I. Joe), a character ...
listening on a Unix socket, ready to be used by any Web server
A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
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
Hello World may refer to:
* "Hello, World!" program, a computer program that outputs or displays the message "Hello, World!"
Music
* "Hello World!" (composition), song by the Iamus computer
* "Hello World" (Tremeloes song), 1969
* "Hello World" ...
application run as a one-liner:
$ plackup -e 'sub '
HTTP::Server::PSGI: Accepting connections at http://0:5000/
The command above starts an HTTP server listening on port
A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as Hamburg, Manch ...
5000 of every local interface (IP address
An Internet Protocol address (IP address) is a numerical label such as that is assigned to a device connected to a computer network that uses the Internet Protocol for communication. IP addresses serve two main functions: network interface i ...
) and returns this 200 OK response to every HTTP request
HTTP (Hypertext Transfer Protocol) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, wher ...
:
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!
References
External links
PSGI and Plack website
Plack documentation
plackup
manual
{{Use dmy dates, date=May 2019
Perl software
Free web server software