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


Python options.port方法代码示例

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


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

示例1: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    parse_command_line()
    app = Application([('/', ChunkHandler)])
    app.listen(options.port, address='127.0.0.1')

    def callback(response):
        response.rethrow()
        assert len(response.body) == (options.num_chunks * options.chunk_size)
        logging.warning("fetch completed in %s seconds", response.request_time)
        IOLoop.current().stop()

    logging.warning("Starting fetch with curl client")
    curl_client = CurlAsyncHTTPClient()
    curl_client.fetch('http://localhost:%d/' % options.port,
                      callback=callback)
    IOLoop.current().start()

    logging.warning("Starting fetch with simple client")
    simple_client = SimpleAsyncHTTPClient()
    simple_client.fetch('http://localhost:%d/' % options.port,
                        callback=callback)
    IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:24,代码来源:chunk_benchmark.py

示例2: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    parse_command_line(final=False)
    parse_config_file(options.config_file)

    app = Application(
        [
            ('/', MainHandler),
            ('/login', LoginHandler),
            ('/logout', LogoutHandler),
        ],
        login_url='/login',
        **options.group_dict('application'))
    app.listen(options.port)

    logging.info('Listening on http://localhost:%d' % options.port)
    IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:18,代码来源:twitterdemo.py

示例3: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    parse_command_line()
    app = tornado.web.Application(
        [
            (r"/", MainHandler),
            (r"/a/message/new", MessageNewHandler),
            (r"/a/message/updates", MessageUpdatesHandler),
            ],
        cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
        template_path=os.path.join(os.path.dirname(__file__), "templates"),
        static_path=os.path.join(os.path.dirname(__file__), "static"),
        xsrf_cookies=True,
        debug=options.debug,
        )
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:18,代码来源:chatdemo.py

示例4: load_httpserver

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def load_httpserver(self, sockets=None, **kwargs):
        if not sockets:
            from tornado.netutil import bind_sockets

            if settings.IPV4_ONLY:
                import socket

                sockets = bind_sockets(options.port, options.address, family=socket.AF_INET)
            else:
                sockets = bind_sockets(options.port, options.address)

        http_server = tornado.httpserver.HTTPServer(self.application, **kwargs)

        http_server.add_sockets(sockets)
        self.httpserver = http_server
        return self.httpserver 
开发者ID:mqingyn,项目名称:torngas,代码行数:18,代码来源:webserver.py

示例5: run

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def run(self):
        """
        Function to Run the server. Server runs on host: 127.0.0.1 and port: 2000 by default. Debug is also set to false
        by default

        Can be overriden by using the config.ini file
        """
        define("port", default=self.port, help="Run on given port", type=int)
        define("host", default=self.host, help="Run on given host", type=str)
        define("debug", default=self.debug, help="True for development", type=bool)

        parse_command_line()

        print(Fore.GREEN + "Starting Bast Server....")
        print(Fore.GREEN + "Bast Server Running on %s:%s" % (options.host, options.port))

        application = Application(self.handler, debug=options.debug)
        server = HTTPServer(application)
        server.listen(options.port, options.host)
        IOLoop.current().start() 
开发者ID:moluwole,项目名称:Bast,代码行数:22,代码来源:bast.py

示例6: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    logging.basicConfig(level=logging.DEBUG, format="%(levelname)8s %(asctime)s %(message)s ")
    logging.debug('Starting up server')
    from tornado.options import define, options
    define("certfile", default="", help="certificate file for secured SSL connection")
    define("keyfile", default="", help="key file for secured SSL connection")

    tornado.options.parse_command_line()
    app = Application()
    if options.certfile and options.keyfile:
        ssl_options = {
          "certfile": options.certfile,
          "keyfile": options.keyfile,
        }
        logging.info("Using SSL for serving requests")
        app.listen(options.port, ssl_options=ssl_options)
    else:
        app.listen(options.port)
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:alumae,项目名称:kaldi-gstreamer-server,代码行数:21,代码来源:master_server.py

示例7: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    parse_command_line()
    app = Application([('/', ChunkHandler)])
    app.listen(options.port, address='127.0.0.1')
    def callback(response):
        response.rethrow()
        assert len(response.body) == (options.num_chunks * options.chunk_size)
        logging.warning("fetch completed in %s seconds", response.request_time)
        IOLoop.instance().stop()

    logging.warning("Starting fetch with curl client")
    curl_client = CurlAsyncHTTPClient()
    curl_client.fetch('http://localhost:%d/' % options.port,
                      callback=callback)
    IOLoop.instance().start()

    logging.warning("Starting fetch with simple client")
    simple_client = SimpleAsyncHTTPClient()
    simple_client.fetch('http://localhost:%d/' % options.port,
                        callback=callback)
    IOLoop.instance().start() 
开发者ID:omererdem,项目名称:honeything,代码行数:23,代码来源:chunk_benchmark.py

示例8: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    app = Application()
    app.listen(options.port)
    loop = asyncio.get_event_loop()
    app.init_with_loop(loop)

    enable_pretty_logging()

    if options.debug:
        env = 'development'
    else:
        env = 'production'

    print(f'Starting {env} server at http://localhost:{options.port}/')
    print('Quit the server with CONTROL-C.')

    loop.run_forever() 
开发者ID:olhoneles,项目名称:politicos,代码行数:19,代码来源:server.py

示例9: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    tornado.options.parse_command_line()

    # Create the global connection pool.
    async with aiopg.create_pool(
        host=options.db_host,
        port=options.db_port,
        user=options.db_user,
        password=options.db_password,
        dbname=options.db_database,
    ) as db:
        await maybe_create_tables(db)
        app = Application(db)
        app.listen(options.port)

        # In this demo the server will simply run until interrupted
        # with Ctrl-C, but if you want to shut down more gracefully,
        # call shutdown_event.set().
        shutdown_event = tornado.locks.Event()
        await shutdown_event.wait() 
开发者ID:DataDog,项目名称:trace-examples,代码行数:22,代码来源:blog.py

示例10: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    os.environ['DJANGO_SETTINGS_MODULE'] = 'demosite.settings' # TODO: edit this
    sys.path.append('./demosite') # path to your project if needed

    parse_command_line()

    wsgi_app = get_wsgi_application()
    container = tornado.wsgi.WSGIContainer(wsgi_app)

    tornado_app = tornado.web.Application(
        [
            ('/hello-tornado', HelloHandler),
            ('.*', tornado.web.FallbackHandler, dict(fallback=container)),
        ])

    server = tornado.httpserver.HTTPServer(tornado_app)
    server.listen(options.port)

    tornado.ioloop.IOLoop.instance().start() 
开发者ID:tamasgal,项目名称:django-tornado,代码行数:21,代码来源:run_tornado.py

示例11: start_server

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def start_server(self):
        """
        启动 tornado 服务
        :return:
        """
        try:
            ins_log.read_log('info', 'progressid: %(progid)s' % dict(progid=options.progid))
            ins_log.read_log('info', 'server address: %(addr)s:%(port)d' % dict(addr=options.addr, port=options.port))
            ins_log.read_log('info', 'web server start sucessfuled.')
            self.io_loop.start()
        except KeyboardInterrupt:
            self.io_loop.stop()
        except:
            import traceback
            ins_log.read_log('error', '%(tra)s'% dict(tra=traceback.format_exc()))
            #Logger.error(traceback.format_exc()) 
开发者ID:yangmv,项目名称:k8sMG,代码行数:18,代码来源:application.py

示例12: _portlistget_action

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def _portlistget_action(self,data):
        '''获取主机对应端口'''
        hostid = data.get('hostid')
        MH = models.HostResult
        MR = models.PortResult

        RH = MH.get()

        query = MR.select().join(MH).where(MH.host_id == hostid).order_by(MR.port)
        ret = []
        for RP in query:
            ret.append({
                'port'      : str(RP.port),
                'service'   : str(RP.service_name),
                'softname'  : str(RP.soft_name),
                'softtype'  : str(RP.soft_type),
                'softver'   : str(RP.soft_ver),
                'note'      : str(RP.response),
            })
        return ret 
开发者ID:shad0w008,项目名称:Scanver,代码行数:22,代码来源:webserver.py

示例13: _portedit_action

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def _portedit_action(self,data):
        '''端口资料更新'''
        hostid = data.get('hostid')
        port = data.get('port')

        MH = models.HostResult
        MP = models.PortResult

        RH = MH.get(MH.host_id == hostid)

        try:
            R = MP.get(MP.hostid == RH, MP.port == port)
        except MP.DoesNotExist:
            R = MP()
            R.host = RH
            R.host_ip = RH.host_ip
            R.port = port
        R.service_name = data.get('service')
        R.soft_name = data.get('softname')
        R.soft_type = data.get('softtype')
        R.soft_ver = data.get('softver')
        R.response = data.get('note')
        R.updatedate = datetime.datetime.now()
        R.save()
        return str(R.port) 
开发者ID:shad0w008,项目名称:Scanver,代码行数:27,代码来源:webserver.py

示例14: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
    settings = {
        'template_path': os.path.join(base_dir, 'templates'),
        'static_path': os.path.join(base_dir, '../static/webssh_static'),
        # 'cookie_secret': uuid.uuid1().hex,
        # 'xsrf_cookies': True,
        'debug': True
    }

    handlers = [
        (r'/',   IndexHandler),
        (r'/ws', WsockHandler)
    ]

    parse_command_line()
    app = tornado.web.Application(handlers, **settings)
    app.listen(options.port, options.address)
    logging.info('Listening on {}:{}'.format(options.address, options.port))
    IOLoop.current().start() 
开发者ID:hequan2017,项目名称:autoops,代码行数:21,代码来源:main.py

示例15: main

# 需要导入模块: from tornado.options import options [as 别名]
# 或者: from tornado.options.options import port [as 别名]
def main():
	parse_command_line()
	get_file_stats('../files/upgrade.bin')
	app = tornado.web.Application(
		[
			(r"/", MainHandler),
			(r"/gw.json", JSONHandler),
			(r"/d.json", JSONHandler),
			('/files/(.*)', FilesHandler, {'path': str('../files/')}),
			(r".*", tornado.web.RedirectHandler, {"url": "http://" + options.addr + "/", "permanent": False}),
		],
		#template_path=os.path.join(os.path.dirname(__file__), "templates"),
		#static_path=os.path.join(os.path.dirname(__file__), "static"),
		debug=options.debug,
	)
	try:
		app.listen(options.port, options.addr)
		print("Listening on " + options.addr + ":" + str(options.port))
		tornado.ioloop.IOLoop.current().start()
	except OSError as err:
		print("Could not start server on port " + str(options.port))
		if err.errno == 98: # EADDRINUSE
			print("Close the process on this port and try again")
		else:
			print(err) 
开发者ID:ct-Open-Source,项目名称:tuya-convert,代码行数:27,代码来源:fake-registration-server.py


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