An Albatross application can be deployed in a web server as a CGI (albatross.cgiapp), FastCGI (albatross.fcgiapp) or mod_python (albatross.apacheapp) application. It can also be deployed as a standalone HTTP server (albatross.httpdapp). To demonstrate each of these deployment options we're going to use a simple, single page application and a series of deployment scripts.

If you want to rebuild this entire example then you can copy all of the following files to a single directory that is accessible to Apache. (Don't forget to make the CGI scripts executable.)

The Application

First, here's the application module,

   1 from albatross import SimpleApp
   3 class Home:
   4     name = 'home'
   5     def page_display(self, ctx):
   6         ctx.run_template('home.html')
   8 class App(SimpleApp):
   9     def __init__(self, base_url, base_dir):
  10         SimpleApp.__init__(
  11             self,
  12             base_url=base_url,
  13             template_path=base_dir,
  14   ,
  15             secret='-=secret=-'
  16             )
  17         self.register_page(, Home())

And here's the home.html template:


One thing to note is that contains no deployment code. It's possible to put the deployment code into the application's main module but we're going to use separate "connector" scripts for this demonstration so that the application code needs no changes.

Deployment Scripts

Web Server

The deployment scripts, or "connector" scripts as I like to call them, are extremely simple. Their only purpose is to create an application instance and connect it to the web server. Hopefully the scripts are obvious so I will not go into much (if any) detail.

As mentioned above, I used Apache to test these. Here's a simple .htaccess file that may help:

Options +ExecCGI
AddHandler cgi-script cgi
AddHandler fastcgi-script fcgi
AddHandler python-program py
PythonHandler connector


CGIs are run from the directory they are in so the application's base_dir can be '.'.


from albatross import cgiapp
import app
theApp = app.App('connector.cgi', '.')


FastCGIs, like CGIs, are run from the directory of the script.


from albatross import fcgiapp
import app
theApp = app.App('connector.fcgi', '.')
while fcgiapp.running():


mod_python programs run inside Apache. mod_python adds the script's directory to the sys.path but the current working directory could be anywhere so this time we need to be explicit about where the application is installed so that the templates can be found.

   1 from albatross import apacheapp
   2 import app
   4 base_dir = '/home/matt/public_html/albatross/deploy'
   6 theApp = app.App('', base_dir)
   7 def handler(req):
   8     return

Standalone Server

The albatross.httpdapp module contains a simple, standalone HTTP server (based on Python's BaseHTTPServer) and a helper script, al-httpd.

from albatross import httpdapp
import app
theApp = app.App('/', '.')

To run it use "al-httpd standalone.theApp 8001".

None: DeploymentOptions (last edited 2011-02-15 06:05:18 by localhost)