當前位置: 首頁>>代碼示例>>Python>>正文


Python simple_server.WSGIServer類代碼示例

本文整理匯總了Python中wsgiref.simple_server.WSGIServer的典型用法代碼示例。如果您正苦於以下問題:Python WSGIServer類的具體用法?Python WSGIServer怎麽用?Python WSGIServer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了WSGIServer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: serve

def serve(site_factory, port=0, use_reloader=False, dry=False):
    """Create a new WSGI server listening on `host` and `port` for `app`"""
    server = WSGIServer(('', port), WSGIRequestHandler)
    server.set_app(site_factory.wsgi())
    LOGGER.info('Serving on port {0}'.format(port))
    if not dry:     #pragma nocover
        server.serve_forever()
開發者ID:pombredanne,項目名稱:djpcms,代碼行數:7,代碼來源:serve.py

示例2: server_close

 def server_close(self):
     """
     Properly initiate closing handshakes on
     all websockets when the WSGI server terminates.
     """
     print "closing sockets"
     _WSGIServer.server_close(self)
開發者ID:dls-controls,項目名稱:malcolm,代碼行數:7,代碼來源:wsserversocket.py

示例3: run_wsgi

def run_wsgi(port=8123):
    server = WSGIServer(('', port), WSGIRequestHandler)
    app = create_publisher()
    server.set_app(app)

    print 'serving on %s:%d' % (interface, port,)
    server.serve_forever()
開發者ID:ctb,項目名稱:waroo,代碼行數:7,代碼來源:web.py

示例4: start_wsgi_server

    def start_wsgi_server():
        from rdb.RobotDebuger import DebugSetting
        app_settings = DebugSetting()
        work_root = os.getcwd()

        config_path = os.path.abspath(config_file)
        if os.path.isfile(config_path):
            app_settings.load_from_file(config_path)
        
        init_sys_logging(app_settings)
        logger = logging.getLogger("rdb.proxy")
        logger.info("Loading RDB proxy at %s" % work_root)
        
        try:
            SERVER_CONTEXT = ApplicationContext(work_root, app_settings)
            globals()['SERVER_CONTEXT'] = SERVER_CONTEXT
            
            from wsgiref.simple_server import WSGIServer
            server_address = (app_settings.WEB_BIND, int(app_settings.WEB_PORT))
            server = WSGIServer(server_address, RDBProxyWSGIHandler)
            server.set_app(wsgi_global_app)
            SERVER_CONTEXT.server = server
            
            logger.info("Serving HTTP on %s:%s..." %(app_settings.WEB_BIND,
                                                          app_settings.WEB_PORT))
            
            server.serve_forever()
        except BaseException, e:
            logger.exception(e)
開發者ID:Tset-Noitamotua,項目名稱:robotframework-debuger,代碼行數:29,代碼來源:standalone.py

示例5: runserver

def runserver():
    """Lance un serveur wsgi de test, puis lui attribue l'application a
    lancer avec eventuellement le chainage de middleware
    """
    from pyson.middleware.error   import HandleError
    from pyson.middleware.log     import Log
    from pyson.middleware.session import Session  #se wrapp automatiquement avec cookie
    from pyson.middleware.force_auth import Force_auth
    from pyson.middleware.http_basic import Http_basic
    from pyson.middleware.formdata import Formdata
    from pyson.middleware.restriction import Middle as Restriction 

    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls)
        print "-------------  Attention ---------------"
    else:
        import wsgiref
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', int(context.conf["port"])), WSGIRequestHandler)

        wrapper  = Session(Formdata((Restriction(urls.urls))))

        httpd.set_app(wrapper)

        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
開發者ID:antoinefarnault,項目名稱:pyson,代碼行數:27,代碼來源:manage.py

示例6: __init__

 def __init__(self, machine_id, host, port, ui):
     self.machine_id = machine_id
     WSGIServer.__init__(self, (host, port), WSGIRequestHandler)
     self.set_app(self.wsgi_app)
     Partner.__init__(self, ui)
     self.text_format = XMLFormat()
     self.stopped = False
     self.sessions = {} # {session_token: session}
     self.session_token_for_user = {} # {user_name: session_token}
開發者ID:bartosh,項目名稱:pomni,代碼行數:9,代碼來源:server.py

示例7: __init__

    def __init__(self, *args, **kwargs):
        WSGIServer.__init__(self, *args, **kwargs)

        # NonBlockingClient -> timestamp
        self.clients = {}
        # Number of simultaneous clients.
        self.limit = 1000
        # Number of seconds before we bounce idle clients.
        self.timeout = 60
        self._shutdown_event = threading.Event()
開發者ID:jesseward,項目名稱:stagehand,代碼行數:10,代碼來源:wsgi.py

示例8: run

def run():
    import urls
    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8000), WSGIRequestHandler)
        httpd.set_app(urls.urls)
        print "Serving HTTP os %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
開發者ID:demonkit,項目名稱:framework_test,代碼行數:11,代碼來源:manage.py

示例9: __init__

    def __init__(self, server_address, HandlerClass):
        WSGIServer.__init__(self, server_address, HandlerClass)
        if self.cert_file:
            ctx = SSL.Context(SSL.SSLv3_METHOD)
            ctx.use_privatekey_file(self.cert_file)
            ctx.use_certificate_file(self.cert_file)

            self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                            self.socket_type))
            self.server_bind()
            self.server_activate()
開發者ID:LittleForker,項目名稱:ajenti,代碼行數:11,代碼來源:standalone.py

示例10: server_close

 def server_close(self):
     """
     Properly initiate closing handshakes on
     all websockets when the WSGI server terminates.
     """
     if hasattr(self, 'manager'):
         self.manager.close_all()
         self.manager.stop()
         self.manager.join()
         delattr(self, 'manager')
     _WSGIServer.server_close(self)
開發者ID:Anderson-Juhasc,項目名稱:bitex,代碼行數:11,代碼來源:wsgirefserver.py

示例11: run

def run():
    import urls

    if os.environ.get('REQUEST_METHOD', ''):
        from wsgiref.handlers import  BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ).run(urls.urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
        httpd = WSGIServer(('', 8080), WSGIRequestHandler)
        httpd.set_app(urls.urls)
        host, port = httpd.socket.getsockname()[:2]
        print 'Serving HTTP on {0} port {1}...'.format(host, port)
        httpd.serve_forever()
開發者ID:EaconTang,項目名稱:PythonWebServer,代碼行數:13,代碼來源:manage.py

示例12: serve

def serve(handler, host='localhost', port=8080, debug=True):
    """
    Starts a developent server on the local machine. By default, the
    server runs on port 8080 on localhost. You can pass in a different
    hostname and/or IP using the keyword arguments.
    """

    if debug:
        handler = DebugMiddleware.wrap(handler)

    httpd = WSGIServer((host, port), WSGIRequestHandler)
    httpd.set_app(WSGIHandler(handler))
    print("Development server is running at http://%s:%s/" % (host, port))
    httpd.serve_forever()
開發者ID:rivrproject,項目名稱:rivr,代碼行數:14,代碼來源:server.py

示例13: get_request

 def get_request(self):
     socket, client_address = WSGIServer.get_request(self)
     socket = ssl.wrap_socket(socket,
                              server_side=True,
                              certfile=SERVER_CERT_FILE,
                              keyfile=SERVER_KEY_FILE)
     return socket, client_address
開發者ID:DhamodharanGH,項目名稱:Vasantha,代碼行數:7,代碼來源:test_rest.py

示例14: run

def run(selector):
    """Run the server provided by selector"""

    print selector
    exec "from  " + selector + " import urls, port"

    if os.environ.get("REQUEST_METHOD", ""):
        from wsgiref.handlers import BaseCGIHandler
        BaseCGIHandler(sys.stdin, sys.stdout, sys.stderr, os.environ) \
                .run(urls)
    else:
        from wsgiref.simple_server import WSGIServer, WSGIRequestHandler
# with the code like this we are binding to no particular interface, matter?
        httpd = WSGIServer(('', port), WSGIRequestHandler)
        httpd.set_app(urls)
        print "Serving HTTP on %s port %s ..." % httpd.socket.getsockname()
        httpd.serve_forever()
開發者ID:cdent,項目名稱:closet,代碼行數:17,代碼來源:manage.py

示例15: get_unix_request

 def get_unix_request(self):
     sock, _ = WSGIServer.get_request(self)
     cred = sock.getsockopt(socket.SOL_SOCKET,
                            socket.SO_PEERCRED,
                            self.csize)
     cred = struct.unpack('3i', cred)
     ret = [sock, ['pid: %i, uid: %i, gid: %i' % cred, 0]]
     return ret
開發者ID:svinota,項目名稱:pyrouted,代碼行數:8,代碼來源:http.py


注:本文中的wsgiref.simple_server.WSGIServer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。