Questions tagged [psgi]

PSGI (Perl Web Server Gateway Interface) is an interface between web servers and Perl-based web applications and frameworks that allows writing portable applications that can be run as standalone servers or using CGI, FastCGI, mod_perl, etc.

PSGI (Perl Web Server Gateway Interface) is an interface between web servers and Perl-based web applications and frameworks that allows writing portable applications that can be run as standalone servers or using CGI, FastCGI, mod_perl, etc. (from: Wikipedia)

This is an example PSGI application:

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

PSGI is inspired by Python's (Web Server Gateway Interface), Ruby's and JSGI for JavaScript.

80 questions
4
votes
2 answers

Perl how to send zip file to browser for download in PSGI

I am started to look at the PSGI, I know the response from the application should be an array ref of three elements, [code, headers, body]: #!/usr/bin/perl my $app = sub { my $env = shift; return [ 200, [ 'Content-type', 'text/plain'…
daliaessam
  • 1,636
  • 2
  • 21
  • 43
4
votes
2 answers

Perl CGI vs FastCGI

I've been programming on Perl for a long time, I've always used CGI technology to build my applications. Now I think to rebuild them and write new ones on FCGI. Please, explain the difference between unsing FastCGI and PSGI with f.e. Starman. Also…
tester3
  • 413
  • 1
  • 4
  • 12
4
votes
1 answer

Using PSGI, is it possible to change how uploaded files are named?

I have a small PSGI app which takes an upload from a form and passes it off to another script for processing: #!/usr/bin/perl use strict; use warnings; use Plack::Request; use HTTPStatusCode; my $app = sub { my $req =…
RobEarl
  • 7,862
  • 6
  • 35
  • 50
3
votes
1 answer

How to turn a static CGI-style perl script(xxx.pl) to a dynamic PSGI application?

CGI-style perl scripts are hard to test in this style: def test_it_says_hello_to_a_person get '/home.pl', :name => 'Simon' assert last_response.body.include?('Simon') end (Note: the code is in ruby, using Rack::Test). But if I can turn static…
winteen
  • 45
  • 6
3
votes
2 answers

How to can one Plack application affect another one?

I have this: use Plack::Builder; my $config_app = sub {...}; my $app = sub {...} builder { mount "/admin" => $config_app; mount "/" => $app; }; the $config_app saving configuration values into file app.cfg and the $app loading it as…
kobame
  • 5,766
  • 3
  • 31
  • 62
3
votes
3 answers

PSGI Response: What kinds of filehandles can be expected to work with PSGI, and Plack?

The PSGI specification defines the HTTP response as consisting of three parts, the third of which may be either an array reference or a filehandle. The filehandle may be: An IO::Handle-like object or a built-in filehandle. And the spec goes on to…
Lumi
  • 14,775
  • 8
  • 59
  • 92
3
votes
1 answer

Configuring directory aliases in Starman (or other PSGI servers)

I am used to setting aliases to different directories in Apache httpd.conf. For example, the following works for me Alias /lib /path/to/lib Then I can include paths such as no matter what the…
punkish
  • 13,598
  • 26
  • 66
  • 101
3
votes
2 answers

Perl PSGI does not serve static files automatically

I am practicing with Perl and PSGI/Plack. Just trying the simple PSGI example app: app.psgi #!/usr/bin/perl my $counter = 0; my $app = sub { my $env = shift; my $path = $env->{PATH_INFO} || $env->{REQUEST_URI}; $counter++; my…
daliaessam
  • 1,636
  • 2
  • 21
  • 43
3
votes
1 answer

Perl benchmark between FCGI and PSGI

What I know about the FCGI protocol is, the first time the application is called, it loads it into memory, run it, return the response to the server, finish the response but does not end the application, it keeps it running in memory, then next…
daliaessam
  • 1,636
  • 2
  • 21
  • 43
3
votes
1 answer

Right Way to Fork in PSGI/Plac application (Perl)

I have a such question - what is a right way to fork in PSGI/Plack application ? On the one hand i know that PSGI app is "backend-agnostic", so it can be runned using different methods - FastCGI,CGI, etc But on the other hand i know that for example…
Vov Pov
  • 101
  • 5
3
votes
1 answer

How to serve static files (images etc.) for a PSGI / Plack web app (in Perl)?

How to serve static files (images, javascript, stylesheets) for a PSGI / Plack based web app? The answer would probably depend on what web server one uses, be it CGI, FastCGI, mod_psgi, or pure-Perl like Starman. I have heard that using…
Jakub Narębski
  • 309,089
  • 65
  • 217
  • 230
2
votes
1 answer

PSGI application with Apache2 using Plack::Handler::Apache2 results in 'not found'

first time poster, long time lurker here. Im using a tiny PSGI application in plackup, but id like to switch to Apache2 for subdomains. I run the application with 'plackup /home/ath88/work/kolle/script/dir.psgi -port 80'. It runs perfectly on…
ath88
  • 296
  • 1
  • 11
2
votes
1 answer

How to know when a PSGI nonblocking streaming writer is ready for more data in a PSGI compatible way?

I'm writing a PSGI middleware and currently running on the Twiggy server. The middleware deals with large (>2GB) dynamically created files and utilising the asynchronous streaming ability of Twiggy/AnyEvent. The PSGI Specification says very briefly…
drclaw
  • 2,463
  • 9
  • 23
2
votes
1 answer

FastCGI, Perl and Exit

I've been honing the performance a large, decades old codebase I use for projects over the last few weeks and it was suggested to me on here that I should look at something like FastCGI or HTTP::Engine. I've found it impressively straightforward to…
Timothy R. Butler
  • 1,097
  • 7
  • 20
2
votes
0 answers

"Cronjob" inside a PSGI script

I have a PSGI script using plack builder which is being executed using uwgsi by having multiple processes spawned. I have to refresh every minute an internal hash by using a database call. Is it somehow possible, independent from outside…