Plack (software)




























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.


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]




Contents






  • 1 PSGI


  • 2 Supported backends


  • 3 Examples


  • 4 References


  • 5 External links





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 March 2010[update][7] Plack supports the following server backends:



  • CGI

  • SCGI

  • FastCGI


  • mod_perl under Apache 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 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..mw-parser-output cite.citation{font-style:inherit}.mw-parser-output q{quotes:"""""""'""'"}.mw-parser-output code.cs1-code{color:inherit;background:inherit;border:inherit;padding:inherit}.mw-parser-output .cs1-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-lock-limited a,.mw-parser-output .cs1-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png")no-repeat;background-position:right .1em center}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration{color:#555}.mw-parser-output .cs1-subscription span,.mw-parser-output .cs1-registration span{border-bottom:1px dotted;cursor:help}.mw-parser-output .cs1-hidden-error{display:none;font-size:100%}.mw-parser-output .cs1-visible-error{font-size:100%}.mw-parser-output .cs1-subscription,.mw-parser-output .cs1-registration,.mw-parser-output .cs1-format{font-size:95%}.mw-parser-output .cs1-kern-left,.mw-parser-output .cs1-kern-wl-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right,.mw-parser-output .cs1-kern-wl-right{padding-right:0.2em}


  2. ^ http://plackperl.org


  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 - search.cpan.org". search.cpan.org. Retrieved 2016-02-20.


  6. ^ chromatic. "Web Application Development with Modern Perl". modernperlbooks.com.


  7. ^ Plack::Handler modules on CPAN



External links



  • PSGI and Plack website

  • Plack documentation


  • plackup manual











Popular posts from this blog

Steve Gadd

Подольск

Лира (музыкальный инструмент)