GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Web::Simple::Deployment(3) User Contributed Perl Documentation Web::Simple::Deployment(3)

Web::Simple::Deployment - various deployment options

This file documents common deployment methods for Web::Simple. If you feel one is missing, please ask in the IRC channel and we'll work with you to add it.

The most basic deployment option is as a CGI script loading and running your Web::Simple-module:

  #!/usr/bin/env perl

  use Your::Web::Simple::App;
  Your::Web::Simple::App->run_if_script;

Save that as script.cgi and your web server will handle it correctly.

This works in with exactly the same code as CGI deployment. However instead of letting your web server load script.cgi, you run this on the command line:

  plackup script.cgi

Sometimes your app is so small that you have only one or two tiny classes that you want to run as a CGI script. Web::Simple offers a helpful mechanism to achieve that.

  #!/usr/bin/env perl

  use Web::Simple 'HelloWorld';   # enables strictures and warnings for the file
                                  # additionally, HelloWorld is upgraded to a
                                  # Web::Simple application
  {
    package HelloWorld;

    sub dispatch_request {
      sub (GET) {
        [
          200,
          [ 'Content-type', 'text/plain' ],
          [ 'Hello world! It is a fine ' . HelloWorld::Helper->day ]
        ]
      },
      sub () {
        [ 405, [ 'Content-type', 'text/plain' ], [ 'Method not allowed' ] ]
      }
    }
  }

  {
    package HelloWorld::Helper;

    use DateTime;

    sub day {
      return DateTime->now->day_name;
    }
  }

  HelloWorld->run_if_script;

See Web::Simple for authors.

See Web::Simple for the copyright and license.
2012-05-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.