Re: CGI package recommendation
by hippo (Bishop) on Jan 24, 2021 at 13:58 UTC
|
CGI.pm is still around and you can use that if you like - it will be fine for a low-traffic site. However it does still come with all the old HTML-generation functions (for backwards compatibility) and those are pretty much universally frowned on these days. I still create some sites using CGI (the protocol) but in most cases use one of the less heavy alternatives like CGI::Lite, CGI::Minimal, etc.
If you are expecting it to be a high-volume site then something with a persistent back-end is going to be a better bet and there are a whole heap of options in that space, including using an FCGI wrapper around plain CGI scripts.
| [reply] |
|
> However it does still come with all the old HTML-generation functions (for backwards compatibility)
You are right, I thought the code was out factored to
CGI::HTML::Functions
But it seems that's only the documentation.
Edit
Major correction 2 min after posting.
| [reply] |
Re: CGI package recommendation
by haukex (Archbishop) on Jan 24, 2021 at 13:07 UTC
|
| [reply] |
Re: CGI package recommendation
by 1nickt (Canon) on Jan 24, 2021 at 13:49 UTC
|
| [reply] |
|
I'll check dancer2 out. I was surprised and pleased when I ssh'ed into my account on the shared webserver system:
Warning: You do not have write permission for Perl library directories
+.
To install modules, you need to configure a local Perl library directo
+ry or
escalate your privileges. CPAN can help you by bootstrapping the loca
+l::lib
module or by configuring itself to use 'sudo' (if available). You may
+ also
resolve this problem manually if you need to customize your setup.
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
[local::lib]
So I guess it'll be easy to install Dancer2 and play with it thanks... | [reply] [d/l] |
Re: CGI package recommendation
by bliako (Monsignor) on Jan 24, 2021 at 13:22 UTC
|
Although I was a big proponent of CGI because of its simplicity, I now use Mojolicious and I am very pleased with it. It's not that mojolicious is not "simple". It's that it needs to have its own webserver running. And it's prefered to have a webserver like nginx or apache proxy to that. Which is fairly simple if your host allows you access. But prohibitive in most free, share-hosting environments. I have switched to mojolicious when I got a VPS (paid server with full control via ssh access) instead of the free shared web-hosting.
| [reply] |
|
Thanks for the advice, but I'm using a shared-hosting environment and so I don't have my own webserver. I cannot even install modules. {although I'll ask the sysops if they are willing to install a CPAN module.}
It'll be a very low traffic "site" and the web pages that the user will see will be pretty simple.
| [reply] |
|
| [reply] |
|
I too operate a number of websites on shared hosting so feel your pain. For a long time I used CGI for processing input from a web form but never to generate the HTML.
However, I ran into a number of random errors that I could not debug. I suspect they were more to do with the hosting environment than the module. The result was I wrote my own code to deal with form and image uploads instead.
| [reply] |
Re: CGI package recommendation
by duelafn (Parson) on Jan 24, 2021 at 20:15 UTC
|
If you're looking for something with that same do-it-yourself feel, I've been using the following template for small one-off scripts. Not apppropriate for a site full of CGI, but if you have a static site with just a couple simple independent dynamic pages, it can be sufficient.
use strict; use warnings; use 5.020;
use utf8;
use Plack::Request;
use Encode;
use JSON::XS;
my $app = sub {
my $req = Plack::Request->new($_[0]);
my $input = decode 'UTF-8', $req->parameters->{'input'};
[
200,
[ 'Content-Type', 'application/json; charset=UTF-8' ],
[ encode_json { output => uc $input } ]
];
};
# To run as a true CGI script, include after the sub:
#use Plack::Handler::CGI;
#Plack::Handler::CGI->new->run($app);
# Or FastCGI for reverse proxy:
# plackup -s FCGI --listen /tmp/fcgi.sock myapp.psgi
# Or persistently for simple direct serve:
# plackup --host 127.0.0.1 --port 9090 script.pl
| [reply] [d/l] |