Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Plack (software)
Web application framework

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 web applications without a live web server.

Plackup is a command line utility to run PSGI applications from the command line.

Related Image Collections Add Image
We don't have any YouTube videos related to Plack (software) yet.
We don't have any PDF documents related to Plack (software) yet.
We don't have any Books related to Plack (software) yet.
We don't have any archived web articles related to Plack (software) yet.

PSGI

PSGI or Perl Web Server Gateway Interface is an interface between web servers and web applications and frameworks written in the Perl programming language that allows writing portable applications that can be run as standalone servers or using CGI, FastCGI, mod_perl, et al.6 It is inspired by the Web Server Gateway Interface for Python, Rack for Ruby and JSGI for JavaScript. A PSGI application is a Perl subroutine that accepts arguments as a single hash reference and returns a reference to an array of three elements: an HTTP status code, a reference to an array of HTTP headers and a reference to an array of HTTP body lines (usually a generated HTML document) or a filehandle-like object.

Supported backends

As of May 2023[update]7 Plack supports the following server backends:

Examples

Using the default standalone HTTP server:

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

Running as a FastCGI daemon listening on a Unix socket, ready to be used by any Web server 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:

$ 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 5000 of every local interface (IP address) 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!

References

  1. Poe, Curtis (2012). Beginning Perl. John Wiley & Sons. p. 484. ISBN 9781118235638. Retrieved 29 October 2018. 9781118235638

  2. "PSGI/Plack - Perl Superglue for Web Frameworks and Web Servers". plackperl.org. Retrieved 9 September 2023. https://plackperl.org/

  3. Quigley, Ellie (2014). Perl by Example. Pearson Education. p. 586. ISBN 9780133760811. Retrieved 29 October 2018. 9780133760811

  4. Chromatic (2015). Modern Perl (Fourth ed.). The Pragmatic Programmers, LLC. p. 134. ISBN 978-1-68050-088-2. 978-1-68050-088-2

  5. "plackup - metacpan.org". metacpan.org. Retrieved 30 May 2023. https://metacpan.org/dist/Plack/view/script/plackup

  6. chromatic. "Web Application Development with Modern Perl". modernperlbooks.com. http://modernperlbooks.com/whitepapers/developers/web-application-development.html

  7. Plack::Handler modules on CPAN https://metacpan.org/search?q=Plack::Handler