当前位置: 首页>>代码示例>>Python>>正文


Python wsgi.WSGIContainer方法代码示例

本文整理汇总了Python中tornado.wsgi.WSGIContainer方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.WSGIContainer方法的具体用法?Python wsgi.WSGIContainer怎么用?Python wsgi.WSGIContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tornado.wsgi的用法示例。


在下文中一共展示了wsgi.WSGIContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_app

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # another thread instead of using our own WSGIContainer, but this
        # fits better in our async testing framework and the wsgiref
        # validator should keep us honest
        return WSGIContainer(validator(WSGIApplication([
            ("/", HelloHandler),
            ("/path/(.*)", PathQuotingHandler),
            ("/typecheck", TypeCheckHandler),
        ]))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:20,代码来源:wsgi_test.py

示例2: tornadoserver

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def tornadoserver():
    setup_logging('tornadoserver')
    app = create_app(parse_options())
    fsh_folder = app.blueprints['flask_statics_helper'].static_folder
    log_messages(app, OPTIONS['--port'], fsh_folder)

    # Setup the application.
    container = wsgi.WSGIContainer(app)
    application = web.Application([
        (r'/static/flask_statics_helper/(.*)', web.StaticFileHandler, dict(path=fsh_folder)),
        (r'/(favicon\.ico)', web.StaticFileHandler, dict(path=app.static_folder)),
        (r'/static/(.*)', web.StaticFileHandler, dict(path=app.static_folder)),
        (r'.*', web.FallbackHandler, dict(fallback=container))
    ])  # From http://maxburstein.com/blog/django-static-files-heroku/
    http_server = httpserver.HTTPServer(application)
    http_server.bind(OPTIONS['--port'])

    # Start the server.
    http_server.start(0)  # Forks multiple sub-processes
    ioloop.IOLoop.instance().start() 
开发者ID:Robpol86,项目名称:Flask-Large-Application-Example,代码行数:22,代码来源:manage.py

示例3: get_app

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def get_app(self):
        wsgi_app = WSGIContainer(self.wsgi_app)

        class Handler(RequestHandler):
            def get(self, *args, **kwargs):
                self.finish(self.reverse_url("tornado"))

        return RuleRouter(
            [
                (
                    PathMatches("/tornado.*"),
                    Application([(r"/tornado/test", Handler, {}, "tornado")]),
                ),
                (PathMatches("/wsgi"), wsgi_app),
            ]
        ) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:18,代码来源:routing_test.py

示例4: get_app

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # another thread instead of using our own WSGIContainer, but this
        # fits better in our async testing framework and the wsgiref
        # validator should keep us honest
        with ignore_deprecation():
            return WSGIContainer(validator(WSGIAdapter(
                Application([
                    ("/", HelloHandler),
                    ("/path/(.*)", PathQuotingHandler),
                    ("/typecheck", TypeCheckHandler),
                ])))) 
开发者ID:tp4a,项目名称:teleport,代码行数:22,代码来源:wsgi_test.py

示例5: get_app

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def get_app(self):
        class HelloHandler(RequestHandler):
            def get(self):
                self.write("Hello world!")

        class PathQuotingHandler(RequestHandler):
            def get(self, path):
                self.write(path)

        # It would be better to run the wsgiref server implementation in
        # another thread instead of using our own WSGIContainer, but this
        # fits better in our async testing framework and the wsgiref
        # validator should keep us honest
        return WSGIContainer(validator(WSGIApplication([
                        ("/", HelloHandler),
                        ("/path/(.*)", PathQuotingHandler),
                        ("/typecheck", TypeCheckHandler),
                        ]))) 
开发者ID:omererdem,项目名称:honeything,代码行数:20,代码来源:wsgi_test.py

示例6: access_validation_factory

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def access_validation_factory(validator):
			"""
			Creates an access validation wrapper using the supplied validator.

			:param validator: the access validator to use inside the validation wrapper
			:return: an access validation wrapper taking a request as parameter and performing the request validation
			"""
			def f(request):
				"""
				Creates a custom wsgi and Flask request context in order to be able to process user information
				stored in the current session.

				:param request: The Tornado request for which to create the environment and context
				"""
				wsgi_environ = tornado.wsgi.WSGIContainer.environ(request)
				with app.request_context(wsgi_environ):
					app.session_interface.open_session(app, request)
					loginManager.reload_user()
					validator(request)
			return f 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:22,代码来源:__init__.py

示例7: run

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def run(self, quiet=None, server=''):
        """ Start the tornado server, run forever.
            'quiet' and 'server' arguments are no longer used, they are keep only for backward compatibility
        """

        try:
            loop = IOLoop()
            http_server = HTTPServer(WSGIContainer(self.app))
            http_server.listen(self.port)
            loop.start()

        except socket.error as serr:
            # Re raise the socket error if not "[Errno 98] Address already in use"
            if serr.errno != errno.EADDRINUSE:
                raise serr
            else:
                logger.warning("""The webserver port {} is already used.
The SnapRobotServer is maybe already run or another software use this port.""".format(self.port)) 
开发者ID:poppy-project,项目名称:pypot,代码行数:20,代码来源:snap.py

示例8: serve

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def serve(get_vec, port):
    app = Flask(__name__)

    app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False
    CORS(app)

    @app.route('/api', methods=['GET'])
    def api():
        query = request.args['query']
        start = time()
        out = get_vec(query)
        end = time()
        print('latency: %dms' % int((end - start) * 1000))
        return jsonify(out)

    print('Starting server at %d' % port)
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(port)
    IOLoop.instance().start() 
开发者ID:uwnlp,项目名称:denspi,代码行数:21,代码来源:serve.py

示例9: build_webapp_thread

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def build_webapp_thread(self, port=constants.DEFAULT_WEB_UI_PORT):
        app.session = self
        http_server = HTTPServer(WSGIContainer(app))
        while True:
            try:
                http_server.listen(port)
            except socket.error as exc:
                # Only handle "Address already in use"
                if exc.errno != errno.EADDRINUSE:
                    raise
                port += 1
            else:
                self._fuzz_data_logger.log_info("Web interface can be found at http://localhost:%d" % port)
                break
        flask_thread = threading.Thread(target=IOLoop.instance().start)
        flask_thread.daemon = True
        return flask_thread 
开发者ID:jtpereyda,项目名称:boofuzz,代码行数:19,代码来源:sessions.py

示例10: test_types

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def test_types(self):
        headers = {"Cookie": "foo=bar"}
        response = self.fetch("/typecheck?foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

        response = self.fetch("/typecheck", method="POST", body="foo=bar", headers=headers)
        data = json_decode(response.body)
        self.assertEqual(data, {})

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly. 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:15,代码来源:wsgi_test.py

示例11: wrap_web_tests_application

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def wrap_web_tests_application():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIApplicationWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIApplication_" + cls.__name__] = WSGIApplicationWrappedTest
    return result 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:12,代码来源:wsgi_test.py

示例12: start

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def start(self):
    # get properties
    flaskHost = Configuration.getFlaskHost()
    flaskPort = Configuration.getFlaskPort()
    flaskDebug = Configuration.getFlaskDebug()
    # logging
    if Configuration.getLogging():
      logfile = Configuration.getLogfile()
      pathToLog = logfile.rsplit('/', 1)[0]
      if not os.path.exists(pathToLog):
        os.makedirs(pathToLog)
      maxLogSize = Configuration.getMaxLogSize()
      backlog = Configuration.getBacklog()
      file_handler = RotatingFileHandler(logfile, maxBytes=maxLogSize, backupCount=backlog)
      file_handler.setLevel(logging.ERROR)
      formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
      file_handler.setFormatter(formatter)
      self.app.logger.addHandler(file_handler)

    if flaskDebug:
      # start debug flask server
      self.app.run(host=flaskHost, port=flaskPort, debug=flaskDebug)
    else:
      # start asynchronous server using tornado wrapper for flask
      # ssl connection
      print("Server starting...")
      if Configuration.useSSL():
        ssl_options = {"certfile": os.path.join(_runPath, "../", Configuration.getSSLCert()),
                        "keyfile": os.path.join(_runPath, "../", Configuration.getSSLKey())}
      else:
        ssl_options = None
      signal.signal(signal.SIGTERM, self.sig_handler)
      signal.signal(signal.SIGINT,  self.sig_handler)

      self.http_server = HTTPServer(WSGIContainer(self.app), ssl_options=ssl_options)
      self.http_server.bind(flaskPort, address=flaskHost)
      self.http_server.start(0)  # Forks multiple sub-processes
      IOLoop.instance().start() 
开发者ID:flipkart-incubator,项目名称:watchdog,代码行数:40,代码来源:api.py

示例13: _start_tornado

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def _start_tornado(self):
        if os.name == 'nt' and sys.version_info > (3, 7):
            import asyncio
            asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
        log.info('Starting Tornado server on %s', _readable_listen_address(self.listen_address, self.listen_port))

        # Max Buffersize set to 200MB            )
        http_server = HTTPServer(WSGIContainer(self.app),
                                 max_buffer_size=209700000,
                                 ssl_options=self.ssl_args)
        http_server.listen(self.listen_port, self.listen_address)
        self.wsgiserver = IOLoop.current()
        self.wsgiserver.start()
        # wait for stop signal
        self.wsgiserver.close(True) 
开发者ID:janeczku,项目名称:calibre-web,代码行数:17,代码来源:server.py

示例14: get_app

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def get_app(self):
        return WSGIContainer(validator(self.wsgi_app)) 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:4,代码来源:wsgi_test.py

示例15: wrap_web_tests

# 需要导入模块: from tornado import wsgi [as 别名]
# 或者: from tornado.wsgi import WSGIContainer [as 别名]
def wrap_web_tests():
    result = {}
    for cls in web_test.wsgi_safe_tests:
        class WSGIWrappedTest(cls):
            def get_app(self):
                self.app = WSGIApplication(self.get_handlers(),
                                           **self.get_app_kwargs())
                return WSGIContainer(validator(self.app))
        result["WSGIWrapped_" + cls.__name__] = WSGIWrappedTest
    return result 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:12,代码来源:wsgi_test.py


注:本文中的tornado.wsgi.WSGIContainer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。