This subtitle is about PET, a Perl application server and RAD environment for web programming. It is similar in many concepts to Tomcat for Java, Rails for Ruby or Zope for Python. There is also a resemblance with Apache::ASP or Catalyst.
PET uses the excellent TT2 as its templating engine, and is built upon a few gazillion CPAN modules. It can be run in different ways, but in production, it is usually run as a daemon, and must be coupled with a webserver that has FastCGI connectivity.
Currently PET only supports Linux. Please see some incomplete and outdated docs for more info.
I am going to include some actual trick and examples here, the purpose being to show what you can achieve using PET.
Comments are switched off for this entry
A very typical web programming task is to take a directory which contains a bunch of images, and create a thumbnail gallery out of it. The Album module does this very professionally, and an actual industry - TGP sites - is built around this idea.
In theory, it is relatively easy to create an album. All you have to do is to list the directory, get the images, resize them and then display the thumbnails on a (HTML) page with links to the original images. So let's make this easey in practice, too!
Using a few PET built-ins, I am going to show you how to create an album without writing any Perl code - using only 6 lines of code. We will have a page list.pet which lists the thumbnails, and another one called show.pet, which shows the big (original) image.
list.pet
<io:getDir=images dir="html/images" exti="jpg|jpeg" />
[% FOREACH image = images %]
<a href="/show.pet?file=images/${image.file}"><image:thumbnail
maxwidth="100" maxheight="100" file=image.path border="0" /></a>
[% END %]
show.pet
<img src="/${Query.file}" />
That's it! Of course this has no extra HTML, so if you want to make it look nice, you have to put in some CSS & DIVs & TABLEs and whatnot, but this is all the
codig you need.
Now let's go into the details!
More »
Number of comments:0