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


Python bottle.run方法代码示例

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


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

示例1: run

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run(self, handler):
        try:
            # First try to use the new version
            from cheroot.ssl.pyopenssl import pyOpenSSLAdapter
            from cheroot import wsgi
            server = wsgi.Server((self.host, self.port), handler, request_queue_size=32)
        except Exception:
            from cherrypy.wsgiserver.ssl_pyopenssl import pyOpenSSLAdapter
            from cherrypy import wsgiserver
            server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler, request_queue_size=32)

        self.srv = server

        # If cert variable is has a valid path, SSL will be used
        # You can set it to None to disable SSL
        server.ssl_adapter = pyOpenSSLAdapter(Config.REST_SSL_CERTFILE,
                                              Config.REST_SSL_KEYFILE,
                                              Config.REST_SSL_CA_CERTS)
        try:
            server.start()
        finally:
            server.stop() 
开发者ID:grycap,项目名称:im,代码行数:24,代码来源:REST.py

示例2: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def main():

    print(banner)
    global STATIC_PATH

    # Get the hindsight module's path on disk to add to sys.path, so we can find templates and static files
    module_path = os.path.dirname(pyhindsight.__file__)
    sys.path.insert(0, module_path)

    # Loop through all paths in system path, to pick up all potential locations for templates and static files.
    # Paths can get weird when the program is run from a different directory, or when the packaged exe is unpacked.
    for potential_path in sys.path:
        potential_template_path = potential_path
        if os.path.isdir(potential_template_path):
            # Insert the current plugin location to the system path, so bottle can find the templates
            bottle.TEMPLATE_PATH.insert(0, potential_template_path)

        potential_static_path = os.path.join(potential_path, 'static')
        if os.path.isdir(potential_static_path):
            STATIC_PATH = potential_static_path

    # webbrowser.open("http://localhost:8080")
    bottle.run(host='localhost', port=8080, debug=True) 
开发者ID:obsidianforensics,项目名称:hindsight,代码行数:25,代码来源:hindsight_gui.py

示例3: error

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def error(code=500):  # 出错处理 -- 写成装饰器函数.
    """ Decorator for error handler. Same as set_error_handler(code, handler)."""

    def wrapper(handler):  # 包裹函数.
        set_error_handler(code, handler)
        return handler

    return wrapper  # 调用 内嵌包裹函数.


###############################################################################
######################## 服务适配器部分 ##########################################
# 1. web Server 这部分代码,多是导入现成的包,自己修改处理的代码,很少.
# 2. 注意这种开发思想.
# 3. 这里有 内嵌函数定义的应用,注意一下.
###############################################################################

# Server adapter   服务适配器部分-定义
# 由全局的run()函数, 定位到此处. 
开发者ID:hhstore,项目名称:annotated-py-bottle,代码行数:21,代码来源:bottle.py

示例4: force_device_backup

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def force_device_backup(id):
    '''
    Forces backup on device with specified id
    '''
    results_dir = CFG.content['folders']['results']['path']
    device_info = get_device_info(id)
    
    try:
        logging.info("Initiating backup for device  %s" % device_info["id"])
        backup_job = BackupClass(device_info, results_dir=results_dir)
        logging.info("Running backup for device  %s" % device_info["id"])
        backup_job.run()
        logging.info("Backup done for for device  %s" % device_info["id"])
    except Exception as e:
        logging.error("Unexpected error in backup. args are: %s" % str(args))
        logging.error(traceback.format_exc()) 
开发者ID:gilestrolab,项目名称:ethoscope,代码行数:18,代码来源:server.py

示例5: run

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run(self, handler): # pragma: no cover
        from cheroot import wsgi
        from cheroot.ssl import builtin
        self.options['bind_addr'] = (self.host, self.port)
        self.options['wsgi_app'] = handler
        certfile = self.options.pop('certfile', None)
        keyfile = self.options.pop('keyfile', None)
        chainfile = self.options.pop('chainfile', None)
        server = wsgi.Server(**self.options)
        if certfile and keyfile:
            server.ssl_adapter = builtin.BuiltinSSLAdapter(
                    certfile, keyfile, chainfile)
        try:
            server.start()
        finally:
            server.stop()
############# 
开发者ID:gilestrolab,项目名称:ethoscope,代码行数:19,代码来源:server.py

示例6: run

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run(host='127.0.0.1', port=10086):
    from bottle import post, run, request, response

    @post('/puppet')
    def serve():
        '''Puppet Web Trading Interface'''
        task = request.json
        if task:
            try:
                return getattr(acc, task.pop('action'))(**task)
            except Exception as e:
                response.bind(status=502)
                return {'puppet': str(e)}
        return {'puppet': '仅支持json格式'}

    print('Puppet version:', __version__)
    acc = Account()
    run(host=host, port=port) 
开发者ID:Raytone-D,项目名称:puppet,代码行数:20,代码来源:runner.py

示例7: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Dragonflow REST server')
    parser.add_argument('--host', type=str, default='127.0.0.1',
                        help='Host to listen on (127.0.0.1)')
    parser.add_argument('--port', type=int, default=8080,
                        help='Port to listen on (8080)')
    parser.add_argument('--config', type=str,
                        default='/etc/dragonflow/dragonflow.ini',
                        help=('Dragonflow config file '
                              '(/etc/dragonflow/dragonflow.ini)'))
    parser.add_argument('--json', type=str,
                        default=None,
                        help=('JSON schema file (None)'))
    args = parser.parse_args()
    global schema_file
    schema_file = args.json
    utils.config_init(None, [args.config])
    bottle.run(host=args.host, port=args.port) 
开发者ID:openstack,项目名称:dragonflow,代码行数:20,代码来源:df_rest_service.py

示例8: download

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def download(url):
    # url[1].send("[MSG], [Started] downloading   " + url[0] + "  resolution below " + url[2])
    result=""
    if (url[2] == "best"):
        result = subprocess.run(["youtube-dl", "-o", "./downfolder/.incomplete/%(title)s.%(ext)s", "-f", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]", "--exec", "touch {} && mv {} ./downfolder/", "--merge-output-format", "mp4", url[0]])
    elif (url[2] == "audio"):
         result = subprocess.run(["youtube-dl", "-o", "./downfolder/.incomplete/%(title)s.%(ext)s", "-f", "bestaudio[ext=m4a]", "--exec", "touch {} && mv {} ./downfolder/", url[0]])
    else:
        resolution = url[2][:-1]
        result = subprocess.run(["youtube-dl", "-o", "./downfolder/.incomplete/%(title)s.%(ext)s", "-f", "bestvideo[height<="+resolution+"]+bestaudio[ext=m4a]", "--exec", "touch {} && mv {} ./downfolder/",  url[0]])

    try:
        if(result.returncode==0):
            url[1].send("[MSG], [Finished] " + url[0] + "  resolution below " + url[2]+", Remain download Count "+ json.dumps(dl_q.qsize()))
            url[1].send("[QUEUE], Remaining download Count : " + json.dumps(dl_q.qsize()))
            url[1].send("[COMPLETE]," + url[2] + "," + url[0])
        else:
            url[1].send("[MSG], [Finished] downloading  failed  " + url[0])
            url[1].send("[COMPLETE]," + "url access failure" + "," + url[0])
    except error:
        print("Be Thread Safe") 
开发者ID:hyeonsangjeon,项目名称:youtube-dl-nas,代码行数:23,代码来源:youtube-dl-server.py

示例9: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def main(args_str=None):
    '''
    Spawn the webserver for Ansible operations
    '''
    sm_pid = os.getpid()
    pid_file = \
    "/var/run/contrail-server-manager/contrail-server-manager-ansible.pid"
    dir = os.path.dirname(pid_file)
    if not os.path.exists(dir):
        os.mkdir(dir)
    f = open(pid_file, "w")
    f.write(str(sm_pid))
    f.close()

    try:
        srvr = SMAnsibleServer(args_str)
        bottle.run(app=srvr.app, host=srvr._args.ansible_srvr_ip,
            port=srvr._args.ansible_srvr_port, debug=True, server='paste')
    except Exception as e:
        print "Container server was not started successfully" 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:22,代码来源:sm_ansible_server.py

示例10: initialize_features

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def initialize_features(self, sm_args, serverdb):
        self.sandesh_init(sm_args, self.monitoring_config_set, self.inventory_config_set)
        self.set_serverdb(serverdb)
        if self.monitoring_config_set:
            self.server_monitoring_obj.set_serverdb(serverdb)
            self.server_monitoring_obj.set_ipmi_defaults(sm_args.ipmi_username, sm_args.ipmi_password)
            self.monitoring_gevent_thread_obj = gevent.spawn(self.server_monitoring_obj.run)
        else:
            self._smgr_log.log(self._smgr_log.ERROR, "Monitoring configuration not set. "
                                                     "You will be unable to get Monitor information of servers.")

        if self.inventory_config_set:
            self.server_inventory_obj.set_serverdb(serverdb)
            self.server_inventory_obj.set_ipmi_defaults(sm_args.ipmi_username, sm_args.ipmi_password)
            self.server_inventory_obj.add_inventory()
        else:
            self._smgr_log.log(self._smgr_log.ERROR, "Inventory configuration not set. "
                                                     "You will be unable to get Inventory information from servers.") 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:20,代码来源:server_mgr_mon_base_plugin.py

示例11: run_in_thread

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run_in_thread(host, port):
    bottle_thr = threading.Thread(target=run, args=(host, port))
    bottle_thr.daemon = True
    bottle_thr.start() 
开发者ID:grycap,项目名称:im,代码行数:6,代码来源:REST.py

示例12: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def main():
    """Function run when the tool is called."""
    args = parse_args()
    print(__doc__)
    application = default_app()
    application.mount('/cgi/', webapp.application)
    run(host=args.bind_address, port=args.port, debug=DEBUG) 
开发者ID:cea-sec,项目名称:ivre,代码行数:9,代码来源:httpd.py

示例13: main

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def main():
    #
    # CLI PARAMS
    #
    parser = argparse.ArgumentParser(description='comSysto GitHub Pages Auth Basic Proxy')

    parser.add_argument("-e", "--environment", help='Which environment.', choices=['cgi', 'wsgi', 'heroku'])
    parser.add_argument("-gho", "--owner", help='the owner of the repository. Either organizationname or username.')
    parser.add_argument("-ghr", "--repository", help='the repository name.')
    parser.add_argument("-obf", "--obfuscator", help='the subfolder-name in gh-pages branch used as obfuscator')
    parser.add_argument("-p", "--port", help='the port to run proxy e.g. 8881')
    parser.add_argument("-a", "--authType", help='how should users auth.', choices=['allGitHubUsers', 'onlyGitHubOrgUsers'], required=False )


    args = parser.parse_args()
    if not args.environment:
        print ('USAGE')
        print ('    proxy that allows only members of the organization to access page: (owner must be an GitHub Organization)')
        print ('      $> cs-gh-proxy -e wsgi -p 8881 --authType onlyGitHubOrgUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3')
        print ('')
        print ('    proxy that allows all GitHub Users to access page: (owner can be GitHub Organization or normal user)')
        print ('      $> cs-gh-proxy -e wsgi -p 8881 --authType allGitHubUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3')
        print ('')

        sys.exit(1)

    if args.environment == 'heroku':
        args = parser.parse_args(['--environment', 'heroku',
                                  '--port',       os.environ.get("PORT", 5000),
                                  '--authType',   os.environ.get("PROXY_AUTH_TYPE", 'allGitHubUsers'),
                                  '--owner',      os.environ.get("GITHUB_REPOSITORY_OWNER", 'comsysto'),
                                  '--repository', os.environ.get("GITHUB_REPOSITORY_NAME", 'github-pages-basic-auth-proxy'),
                                  '--obfuscator', os.environ.get("GITHUB_REPOSITORY_OBFUSCATOR", '086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3')
                                 ])

    run_proxy(args)

#
# global vars
# 
开发者ID:comsysto,项目名称:github-pages-basic-auth-proxy,代码行数:42,代码来源:proxy.py

示例14: run

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run(self):
        bottle.run(host=self.host, port=self.port, debug=True) #quiet=True 
开发者ID:nfvlabs,项目名称:openmano,代码行数:4,代码来源:httpserver.py

示例15: run_bottle

# 需要导入模块: import bottle [as 别名]
# 或者: from bottle import run [as 别名]
def run_bottle(db, host_='localhost', port_=9090):
    '''used for launching in main thread, so that it can be debugged'''
    global mydb
    mydb = db
    bottle.run(host=host_, port=port_, debug=True) #quiet=True 
开发者ID:nfvlabs,项目名称:openmano,代码行数:7,代码来源:httpserver.py


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