Plack (software)

Last updated
Plack
Original author(s) Tatsuhiko Miyagawa
Developer(s) Tatsuhiko Miyagawa, Tokuhiro Matsuno, Jesse Luehrs, Tomas Doran, Graham Knop and others.
Written in Perl
License Perl license (Artistic License v2 + GNU General Public License v1)
Website plackperl.org
An example of server-side scripting using Perl, Plack and PSGI. Mod perl plack.png
An example of server-side scripting using Perl, Plack and PSGI.

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]

Contents

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

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

Examples

Using the default standalone HTTP server:

$ plackupapp.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-sFCGI-listen/tmp/fcgi.sockapp.psgi FastCGI: manager (pid 3336): initializedFastCGI: manager (pid 3336): server (pid 3337) startedFastCGI: 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.0200OKDate:Fri, 19 Mar 2010 23:34:10 GMTServer:HTTP::Server::PSGIContent-Type:text/plainContent-Length:13  Hello, world! 

Related Research Articles

In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program to process HTTP or HTTPS user requests.

Server-side scripting is a technique used in web development which involves employing scripts on a web server which produces a response customized for each user's (client's) request to the website. Scripts can be written in any of a number of server-side scripting languages that are available. Server-side scripting is distinguished from client-side scripting where embedded scripts, such as JavaScript, are run client-side in a web browser, but both techniques are often used together. The alternative to either or both types of scripting is for the web server itself to deliver a static web page.

<span class="mw-page-title-main">WebGUI</span> Open-source content management system

WebGUI is an open-source content management system written in Perl and released under the GNU General Public License.

lighttpd

lighttpd is an open-source web server optimized for speed-critical environments while remaining standards-compliant, secure and flexible. It was originally written by Jan Kneschke as a proof-of-concept of the c10k problem – how to handle 10,000 connections in parallel on one server, but has gained worldwide popularity. Its name is a portmanteau of "light" and "httpd".

The Web Server Gateway Interface 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, version 1.0.1, is specified in Python Enhancement Proposal (PEP) 3333.

CherryPy is an object-oriented web application framework using the Python programming language. It is designed for rapid development of web applications by wrapping the HTTP protocol but stays at a low level and does not offer much more than what is defined in RFC 7231.

<span class="mw-page-title-main">Django (web framework)</span> Python web framework

Django is a free and open-source, Python-based web framework that runs on a web server. It follows the model–template–views (MTV) architectural pattern. It is maintained by the Django Software Foundation (DSF), an independent organization established in the US as a 501(c)(3) non-profit.

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-running service process to continue serving requests, thus avoiding delays in responding to requests due to setup overhead.

<span class="mw-page-title-main">Catalyst (software)</span>

Catalyst is an open source web application framework written in Perl, that closely follows the model–view–controller (MVC) architecture, and supports a number of experimental web patterns. It is written using Moose, a modern object system for Perl. Its design is heavily inspired by frameworks such as Ruby on Rails, Maypole, and Spring.

A webform, web form or HTML form on a web page allows a user to enter data that is sent to a server for processing. Forms can resemble paper or database forms because web users fill out the forms using checkboxes, radio buttons, or text fields. For example, forms can be used to enter shipping or credit card data to order a product, or can be used to retrieve search results from a search engine.

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".

Web2py is an open-source web application framework written in the Python programming language. Web2py allows web developers to program dynamic web content using Python. Web2py is designed to help reduce tedious web development tasks, such as developing web forms from scratch, although a web developer may build a form from scratch if required.

mod_lisp is an extension module for the Apache HTTP Server. It enables Apache to interface with application servers written in Common Lisp, making it possible to dynamically generate web pages and provide web applications with Common Lisp programs.

Phusion Passenger is a free web server and application server with support for Ruby, Python and Node.js. It is designed to integrate into the Apache HTTP Server or the nginx web server, but also has a mode for running standalone without an external web server. Phusion Passenger supports Unix-like operating systems, and is available as a gem package, as a tarball, or as native Linux packages.

<span class="mw-page-title-main">Rack (web server interface)</span> API specification for web applications in programming language Ruby

Rack is a modular interface between web servers and web applications developed in the Ruby programming language. With Rack, application programming interfaces (APIs) for web frameworks and middleware are wrapped into a single method call handling HTTP requests and responses.

mod_proxy is an optional module for the Apache HTTP Server.

<span class="mw-page-title-main">Dancer (software)</span> Web framework

Dancer is an open source lightweight web application framework written in Perl and inspired by Ruby's Sinatra.

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 programs, allowing a server to handle more web page requests per unit of time.

The following outline is provided as an overview of and topical guide to the Perl programming language:

The Asynchronous Server Gateway Interface (ASGI) is a calling convention for web servers to forward requests to asynchronous-capable Python programming language frameworks, and applications. It is built as a successor to the Web Server Gateway Interface (WSGI).

References

  1. Poe, Curtis (2012). Beginning Perl. John Wiley & Sons. p. 484. ISBN   9781118235638 . Retrieved 29 October 2018.
  2. "PSGI/Plack - Perl Superglue for Web Frameworks and Web Servers". plackperl.org. Retrieved 9 September 2023.
  3. Quigley, Ellie (2014). Perl by Example. Pearson Education. p. 586. ISBN   9780133760811 . Retrieved 29 October 2018.
  4. Chromatic (2015). Modern Perl (Fourth ed.). The Pragmatic Programmers, LLC. p. 134. ISBN   978-1-68050-088-2.
  5. "plackup - metacpan.org". metacpan.org. Retrieved 30 May 2023.
  6. chromatic. "Web Application Development with Modern Perl". modernperlbooks.com.
  7. Plack::Handler modules on CPAN