Plack (software) explained

Plack
Author:Tatsuhiko Miyagawa
Developer:Tatsuhiko Miyagawa, Tokuhiro Matsuno, Jesse Luehrs, Tomas Doran, Graham Knop and others.
Programming Language:Perl
License:Perl license (Artistic License v2 + GNU General Public License v1)

Plack is a Perl web application programming framework inspired by Rack for Ruby and WSGI for Python,[1] [2] and it is the project behind the PSGI specification used by other frameworks such as Catalyst and Dancer.[3] Plack allows for testing of Perl web applications without a live web server.[4]

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

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

[7] Plack supports the following server backends:

Examples

Using the default standalone HTTP server:$ plackup app.psgiHTTP::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.psgiFastCGI: manager (pid 3336): initializedFastCGI: manager (pid 3336): server (pid 3337) startedFastCGI: server (pid 3337): initializedA working 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 5000 of every local interface (IP address) and returns this 200 OK response to every HTTP request:HTTP/1.0 200 OKDate: Fri, 19 Mar 2010 23:34:10 GMTServer: HTTP::Server::PSGIContent-Type: text/plainContent-Length: 13

Hello, world!

External links

Notes and References

  1. Book: Poe . Curtis . Beginning Perl . 2012 . John Wiley & Sons . 9781118235638 . 484 . 29 October 2018 . en.
  2. Web site: PSGI/Plack - Perl Superglue for Web Frameworks and Web Servers . 2023-09-09 . plackperl.org.
  3. Book: Quigley . Ellie . Perl by Example . 2014 . Pearson Education . 9780133760811 . 586 . 29 October 2018 . en.
  4. Book: Chromatic . Modern Perl . 2015 . The Pragmatic Programmers, LLC . 978-1-68050-088-2 . 134 . Fourth .
  5. Web site: plackup - metacpan.org. metacpan.org. 2023-05-30.
  6. Web site: chromatic . Web Application Development with Modern Perl . modernperlbooks.com . en.
  7. https://metacpan.org/search?q=Plack::Handler Plack::Handler modules on CPAN