예제 #1
0
파일: app.py 프로젝트: ltucker/radarpost
    def __call__(self, address=None):
        """
        start development web server
        address - where to serve, [interface:]port
        """
        if address is not None:
            interface = '127.0.0.1'
            port = address
            if ':' in port:
                interface, port = port.split(':')
            try:
                port = int(port)
            except: 
                raise InvalidArguments('Unable to parse port "%s"' % address)
        else:
            interface = '127.0.0.1'
            port = DEFAULT_RADAR_PORT

        from cherrypy.wsgiserver import CherryPyWSGIServer as WSGIServer

        app = RequestLogger(make_app(self.config))
        cherry_opts = config_section('cherrypy', self.config) 
        server = WSGIServer((interface, port), app, **cherry_opts)
        
        print "* serving on %s:%d" % (interface, port)
        try:
            server.start()
        except KeyboardInterrupt:
            server.stop()        
예제 #2
0
파일: app.py 프로젝트: ltucker/radarpost
def make_app(config, ContextType=RequestContext):
    """
    builds a full application stack.  These can be composed
    and configured elsewhere / differently as needed.
    """
    app = Application(config, ContextType=ContextType)
    app = RoutesMiddleware(wsgi_app=app, mapper=build_routes(config),
                           use_method_override=False, singleton=False)

    beaker_options = config_section('beaker.session.',
                                    config, reprefix='session.')
    if len(beaker_options) > 0:
        app = SessionMiddleware(app, beaker_options)
    return app
예제 #3
0
파일: http.py 프로젝트: ltucker/radarpost
def create_client(cfg):
    """
    create an http client according to 
    the configuration given.
    """

    cfg = config_section('http', cfg)
    
    kw = {}
    if 'timeout' in cfg: 
        kw['timeout'] = cfg['timeout']    
    if 'cache' in cfg:
        kw['cache'] = cfg['cache']
    
    if cfg.get('allow_local') == True: 
        client = UnrestrictedHttp(**kw)
    else:
        client = RestrictedHttp(**kw)

    client.force_exception_to_status_code = True
    
    return client