#!/usr/bin/env python
#
# Copyright 2003 by Object Craft P/L, Melbourne, Australia.
#
# LICENCE - see LICENCE file distributed with this software for details.
#
# AUTHOR(S)
#       Matt Goodall <matt AT pollenation DOT net>

import os
import sys
from albatross import httpdapp


if __name__ == '__main__':
    # Append the current working directory to the path.
    sys.path.append(os.getcwd())

    # Parse the command line.
    try:
        app_module, app_object = sys.argv[1].split('.')
        port = int(sys.argv[2])
    except:
        sys.exit('usage: %s main-module.app-object port'
                 % os.path.basename(sys.argv[0]))

    # Load the application's module and get application instance.
    module = __import__(app_module)
    app = getattr(module, app_object)

    # Create the HTTP server and serve requests.
    httpd = httpdapp.HTTPServer(app, port)
    httpd.serve_forever()
