Created
November 23, 2018 20:58
-
-
Save emil-perhinschi/8d8abed2d3c7e767c2d562a2a83283b5 to your computer and use it in GitHub Desktop.
cgi script with plack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName test-cgi | |
ServerAdmin webmaster@localhost | |
DocumentRoot /home/www/test_cgi/htdocs | |
ErrorLog /home/www/test_cgi/logs/error.log | |
CustomLog /home/www/test_cgi/logs/access.log combined | |
<IfModule mod_alias.c> | |
<IfModule mod_cgi.c> | |
Define ENABLE_USR_LIB_CGI_BIN | |
</IfModule> | |
<IfDefine ENABLE_USR_LIB_CGI_BIN> | |
AddHandler cgi-script .cgi .pl | |
<Directory "/home/www/test_cgi/htdocs"> | |
AllowOverride None | |
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |
Require all granted | |
</Directory> | |
</IfDefine> | |
</IfModule> | |
</VirtualHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Plack::Request; | |
my $app = sub { | |
my $req = Plack::Request->new($_[0]); | |
my $test = $req->param('test'); | |
[ 200, [ 'Content-Type', 'text/html; charset=UTF-8' ], [ "Hello " . $test ] ]; | |
}; | |
use Plack::Handler::CGI; | |
Plack::Handler::CGI->new->run($app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
put test.pl in /home/www/test_cgi/htdocs/, make it executable by the web server user, load http://test-cgi/test.pl?test=asdf