PSGI
Encyclopedia
PSGI or Perl Web Server Gateway Interface is an interface
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...

 between Web server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

s and Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

-based Web application
Web application
A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...

s and frameworks
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...

 that allows writing portable applications that can be run as standalone servers or using CGI
Common Gateway Interface
The Common Gateway Interface is a standard method for web servers software to delegate the generation of web pages to executable files...

, FastCGI
FastCGI
FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface ; FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page...

, mod perl
Mod perl
mod_perl is an optional module for the Apache HTTP server. It embeds a Perl interpreter into the Apache server, so that dynamic content produced by Perl scripts can be served in response to incoming requests, without the significant overhead of re-launching the Perl interpreter for each request...

, et al. It is inspired by the Web Server Gateway Interface for Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

, Rack
Rack (web server interface)
Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between into a single method call.Rack is...

 for Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

 and JSGI
JSGI
JSGI 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 a reference JSGI implementation.- External links :...

 for JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

.

A PSGI application is a Perl subroutine
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

 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
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

 document) or a filehandle-like object
Object (computer science)
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure...

.

Plack
Plack (software)
Plack is a set of tools for running Perl-based Web applications and frameworks compatible with the PSGI specification.Plack was inspired by Rack for Ruby and Paste for Python.Plackup is a command-line tool for running the PSGI applications,...

 is a reference PSGI implementation.

Web frameworks with PSGI support:
  • Catalyst
    Catalyst (software)
    Catalyst is an open source web application framework written in Perl, that closely follows the model–view–controller architecture, and supports a number of experimental web patterns. It is written using Moose, a modern object system for Perl...

  • CGI::Application
  • Continuity
  • Dancer
  • HTTP::Engine
  • Mason
    Mason (Perl)
    HTML::Mason, or Mason for short, is a web application framework written in Perl. It is distributed on CPAN.Its features make it a suitable backend for high load sites serving dynamic content, such as online newspapers or database driven e-commerce sites. The author claims that several popular web...

  • Maypole
    Maypole framework
    Maypole is a Perl web application framework for MVC-oriented applications. Maypole is designed to minimize coding requirements for creating simple web interfaces to databases, while remaining flexible enough to support enterprise web applications...

  • Mojolicious
    Mojolicious
    Mojolicious is a real-time web application framework, written by Sebastian Riedel, creator of the web application framework Catalyst. Licensed as free software under the Artistic License v 2.0, It is written in Perl, and is designed for use in both simple and complex web applications, based on...

  • Piglet
  • Squatting
  • Starman
  • Tatsumaki

Example Application

This is an example hello world
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 PSGI application:


my $app = sub {
return [200, ['Content-Type' => 'text/plain'], ["hello, world\n"]];
}


Save this file as hello.psgi and run it from the command-line: plackup
Plack (software)
Plack is a set of tools for running Perl-based Web applications and frameworks compatible with the PSGI specification.Plack was inspired by Rack for Ruby and Paste for Python.Plackup is a command-line tool for running the PSGI applications,...

hello.psgi

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK