
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
The Web Server Gateway Interface (WSGI, pronounced ''whiskey'' or ) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, ve ...
for
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
,
and it is the project behind the
PSGI
Plack is a Perl web application programming framework inspired by Rack for Ruby and WSGI for Python, and it is the project behind the PSGI specification used by other frameworks such as Catalyst and Dancer. Plack allows for testing of Perl w ...
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
A console application or command-line program is a computer program (application program, applications or utility software, utilities) designed to be used via a text-only user interface.
A console application can be used with a computer termina ...
to run PSGI applications from the command line.
PSGI
PSGI or Perl Web Server Gateway Interface is an
interface
Interface or interfacing may refer to:
Academic journals
* ''Interface'' (journal), by the Electrochemical Society
* '' Interface, Journal of Applied Linguistics'', now merged with ''ITL International Journal of Applied Linguistics''
* '' Inter ...
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
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl Interpreter (computing), interpreter into the Apache server. In addition to allowing Apache modules to be written in the Perl programming language, it allows the Apache ...
, et al.
It is inspired by the
Web Server Gateway Interface
The Web Server Gateway Interface (WSGI, pronounced ''whiskey'' or ) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, ...
for
Python
Python may refer to:
Snakes
* Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia
** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia
* Python (mythology), a mythical serpent
Computing
* Python (prog ...
,
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
JSGI, or JavaScript Gateway Interface, is an interface between web servers and JavaScript-based web applications and frameworks. It was inspired by the Rack for Ruby and WSGI for Python and was one of the inspirations of PSGI for Perl.
is ...
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
An array is a systematic arrangement of similar objects, usually in rows and columns.
Things called an array include:
{{TOC right
Music
* In twelve-tone and serial composition, the presentation of simultaneous twelve-tone sets such that the ...
of three elements: an
HTTP status code
Hypertext Transfer Protocol (HTTP) response status codes are issued by a server in response to a client's request made to the server. It includes codes from IETF Request for Comments (RFCs), other specifications, and some additional codes use ...
, 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
The Simple Common Gateway Interface (SCGI) is a protocol for applications to interface with HTTP servers, as an alternative to the CGI protocol. It is similar to FastCGI but is designed to be easier to parse. Unlike CGI, it permits a long-runnin ...
* 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
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl Interpreter (computing), interpreter into the Apache server. In addition to allowing Apache modules to be written in the Perl programming language, it allows the Apache ...
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
A web server is computer software and underlying hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initiates ...
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