Beispiel #1
0
def main(args=None):
    from quixote.server.util import get_server_parser
    if args is None:
        args = sys.argv[1:]
    parser = get_server_parser(run.__doc__)
    (options, args) = parser.parse_args(args=args)
    run(import_object(options.factory), host=options.host, port=options.port)
Beispiel #2
0
def main():
    from optparse import OptionParser
    from quixote.util import import_object
    parser = OptionParser()
    parser.set_description(run.__doc__)
    default_host = 'localhost'
    parser.add_option(
        '--host', dest="host", default=default_host, type="string",
        help="Host interface to listen on. (default=%s)" % default_host)
    default_port = 3000
    parser.add_option(
        '--port', dest="port", default=default_port, type="int",
        help="Port to listen on. (default=%s)" % default_port)
    default_maxchild = 5
    parser.add_option(
        '--max-children', dest="maxchild", default=default_maxchild,
        type="string",
        help="Maximum number of children to spawn. (default=%s)" %
            default_maxchild)
    parser.add_option(
        '--script-name', dest="script_name", default=None, type="string",
        help="Value of SCRIPT_NAME (only needed if using mod_scgi)")
    default_factory = 'quixote.demo.create_publisher'
    parser.add_option(
        '--factory', dest="factory",
        default=default_factory,
        help="Path to factory function to create the site Publisher. "
             "(default=%s)" % default_factory)
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port,
        script_name=options.script_name, max_children=options.maxchild)
def main():
    parser = get_server_parser(MAIN_DOC)
    parser.add_option('--thread', dest='thread', action='store_true',
        help=THREAD_HELP)
    options = parser.parse_args()[0]
    factory = import_object(options.factory)
    if options.thread:
        run_multithreaded(factory, host=options.host, port=options.port)
    else:
        run(factory, host=options.host, port=options.port)
Beispiel #4
0
def main():
    parser = get_server_parser(MAIN_DOC)
    parser.add_option('--thread',
                      dest='thread',
                      action='store_true',
                      help=THREAD_HELP)
    options = parser.parse_args()[0]
    factory = import_object(options.factory)
    if options.thread:
        run_multithreaded(factory, host=options.host, port=options.port)
    else:
        run(factory, host=options.host, port=options.port)
Beispiel #5
0
def handler(req):
    opts = req.get_options()
    try:
        factory = opts['quixote-publisher-factory']
    except KeyError:
        apache.log_error('quixote-publisher-factory setting required')
        return apache.HTTP_INTERNAL_SERVER_ERROR
    pub = name2publisher.get(factory)
    if pub is None:
        factory_fcn = import_object(factory)
        pub = factory_fcn()
        name2publisher[factory] = pub
    return run(pub, req)
Beispiel #6
0
def handler(req):
    opts = req.get_options()
    try:
        factory = opts['quixote-publisher-factory']
    except KeyError:
        apache.log_error('quixote-publisher-factory setting required')
        return apache.HTTP_INTERNAL_SERVER_ERROR
    pub = name2publisher.get(factory)
    if pub is None:
        factory_fcn = import_object(factory)
        pub = factory_fcn()
        name2publisher[factory] = pub
    return run(pub, req)
Beispiel #7
0
def main(args=None):
    from quixote.server.util import get_server_parser
    if args is None:
        args = sys.argv[1:]
    parser = get_server_parser(run.__doc__)
    parser.add_option(
        '--https', dest="https", default=False, action="store_true",
        help=("Force the scheme for all requests to be https.  "
              "Not that this is for running the simple server "
              "through a proxy or tunnel that provides real SSL "
              "support.  The simple server itself does not. "))
    (options, args) = parser.parse_args(args=args)
    run(import_object(options.factory), host=options.host, port=options.port,
        https=options.https)
Beispiel #8
0
def main(run):
    parser = get_server_parser(run.__doc__)
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port)
Beispiel #9
0
def main(run):
    parser = get_server_parser(run.__doc__)
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port)
Beispiel #10
0
        return self.process(self.get_cgi_env('GET'))


def run(create_publisher, host='', port=80, https=False):
    """Runs a simple, single threaded, synchronous HTTP server that
    publishes a Quixote application.
    """
    if https:
        HTTPRequestHandler.required_cgi_environment['HTTPS'] = 'on'
    httpd = HTTPServer((host, port), HTTPRequestHandler)
    publisher = create_publisher()
    httpd.serve_forever()


if __name__ == '__main__':
    from quixote.server.util import get_server_parser
    parser = get_server_parser(run.__doc__)
    parser.add_option('--https',
                      dest="https",
                      default=False,
                      action="store_true",
                      help=("Force the scheme for all requests to be https.  "
                            "Not that this is for running the simple server "
                            "through a proxy or tunnel that provides real SSL "
                            "support.  The simple server itself does not. "))
    (options, args) = parser.parse_args()
    run(import_object(options.factory),
        host=options.host,
        port=options.port,
        https=options.https)
Beispiel #11
0
    def do_POST(self):
        return self.process(self.get_cgi_env('POST'))

    def do_GET(self):
        return self.process(self.get_cgi_env('GET'))


def run(create_publisher, host='', port=80, https=False):
    """Runs a simple, single threaded, synchronous HTTP server that
    publishes a Quixote application.
    """
    if https:
        HTTPRequestHandler.required_cgi_environment['HTTPS'] = 'on'
    httpd = HTTPServer((host, port), HTTPRequestHandler)
    publisher = create_publisher()
    httpd.serve_forever()


if __name__ == '__main__':
    from quixote.server.util import get_server_parser
    parser = get_server_parser(run.__doc__)
    parser.add_option(
        '--https', dest="https", default=False, action="store_true",
        help=("Force the scheme for all requests to be https.  "
              "Not that this is for running the simple server "
              "through a proxy or tunnel that provides real SSL "
              "support.  The simple server itself does not. "))
    (options, args) = parser.parse_args()
    run(import_object(options.factory), host=options.host, port=options.port,
        https=options.https)