Python bottle 模块,debug() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用bottle.debug()

项目:Mmrz-Sync    作者:zhanglintc    | 项目源码 | 文件源码
def download_wordbook():
    username = request.params.get('username', None)
    password = request.params.get('password', None)

    dict_for_return = dict(universal_POST_dict)
    if not verify_login(username, password):
        dict_for_return['verified'] = False
        dict_for_return['message_str'] = "login failed"
        dict_for_return['wordbook'] = []
        json_for_return = json.dumps(dict_for_return)
        return json_for_return
    else:
        dbMgr = MmrzSyncDBManager(username)
        dbMgr.createDB()
        rows = dbMgr.readAllDB()
        dbMgr.closeDB()
        dict_for_return['verified'] = True
        dict_for_return['message_str'] = "Download success"
        dict_for_return['wordbook'] = rows
        json_for_return = json.dumps(dict_for_return)
        return json_for_return

# show serving IP (for debug)
项目:experiment-manager    作者:softfire-eu    | 项目源码 | 文件源码
def setup_app() -> (SessionMiddleware, int, bool):
    bottle.debug(True)
    p = get_config(section='api', key='port', default=5080)
    bottle.install(error_translation)
    session_opts = {
        'session.cookie_expires': True,
        'session.encrypt_key': get_config('api', 'encrypt_key', 'softfire'),
        'session.httponly': True,
        'session.timeout': 3600 * 24,  # 1 day
        'session.type': 'cookie',
        'session.validate_key': True,
    }
    a = SessionMiddleware(bottle.app(), session_opts)
    qb = get_config('api', 'quiet', 'true').lower() == 'true'
    logger.debug("Bootlepy quiet mode: %s" % qb)
    return a, p, qb
项目:memex-dossier-open    作者:dossier    | 项目源码 | 文件源码
def get_application():
    config = Config()
    p = argparse.ArgumentParser(description='Run Memex Dossier Stack web services.')
    web.add_cli_arguments(p)
    args = yakonfig.parse_args(p, [dblogger, config, kvlayer, yakonfig])

    bottle.debug(True)
    app = (web.WebBuilder()
           .set_config(config)
           .enable_cors()
           .inject('tfidf', lambda: config.tfidf)
           .inject('google', lambda: config.google)
           .inject('akagraph', lambda: config.akagraph)
           .inject('akagraph_replicas', lambda: config.akagraph_replicas)
           .add_routes(models_app)
           .get_app())
    return args, app
项目:icfpc2016-judge    作者:icfpc2016    | 项目源码 | 文件源码
def setup_common():
    FLAGS(sys.argv)
    _setup_logging()
    settings.validate()
    eventlog.connect()
    _setup_bottle()
    if FLAGS.debug:
        bottle.debug()
项目:detectem    作者:alertot    | 项目源码 | 文件源码
def main():
    bottle.debug(DEBUG)
    run(host='0.0.0.0', port=5723)
项目:experiment-manager    作者:softfire-eu    | 项目源码 | 文件源码
def book_resources():
    data = request.files.get('data')
    logger.debug("files: %s" % list(request.files.keys()))
    for file in request.files:
        logger.debug("file %s" % file)
    logger.debug("Data: '%s'" % data)
    # logger.debug("Data.file: %s" % data.file)
    if data and data.file:
        Experiment(data.file, username=aaa.current_user.username).reserve()
        bottle.redirect('/experimenter')
    logger.debug(("got body: %s" % request.body.read()))
    raise FileNotFoundError("File not found in your request")
项目:experiment-manager    作者:softfire-eu    | 项目源码 | 文件源码
def register():
    """Send out registration email"""
    logger.debug(("got body: %s" % request.body.read().decode("utf-8")))
    if check_if_authorized(post_get('username')):
        aaa.create_user(post_get('username'), 'user', post_get('password'))
    else:
        return dict(
            ok=False,
            msg="username not pre authorized"
        )
    return 'User created'


# @bottle.post('/reset_password')
# def send_password_reset_email():
#     """Send out password reset email"""
#     aaa.send_password_reset_email(
#         username=post_get('username'),
#         email_addr=post_get('email_address')
#     )
#     return 'Please check your mailbox.'


# @bottle.post('/change_password')
# def change_password():
#     """Change password"""
#     aaa.reset_password(post_get('reset_code'), post_get('password'))
#     return 'Thanks. <a href="/login">Go to login</a>'
项目:experiment-manager    作者:softfire-eu    | 项目源码 | 文件源码
def show_current_user_role():
    """Show current user role"""
    session = bottle.request.environ.get('beaker.session')
    logger.debug("Session from simple_webapp", repr(session))
    aaa.require(fail_redirect='/login')
    return aaa.current_user.role


###############
# Admin pages #
###############
项目:experiment-manager    作者:softfire-eu    | 项目源码 | 文件源码
def register():
    """Send out registration email"""
    logger.debug(("got body: %s" % request.body.read().decode("utf-8")))
    add_authorized_experimenter(post_get('username'))
    return 'User created'
项目:find-that-charity    作者:TechforgoodCAST    | 项目源码 | 文件源码
def main():

    parser = argparse.ArgumentParser(description='')  # @TODO fill in

    # server options
    parser.add_argument('-host', '--host', default="localhost", help='host for the server')
    parser.add_argument('-p', '--port', default=8080, help='port for the server')
    parser.add_argument('--debug', action='store_true', dest="debug", help='Debug mode (autoreloads the server)')
    parser.add_argument('--server', default="auto", help='Server backend to use (see http://bottlepy.org/docs/dev/deployment.html#switching-the-server-backend)')

    # elasticsearch options
    parser.add_argument('--es-host', default="localhost", help='host for the elasticsearch instance')
    parser.add_argument('--es-port', default=9200, help='port for the elasticsearch instance')
    parser.add_argument('--es-url-prefix', default='', help='Elasticsearch url prefix')
    parser.add_argument('--es-use-ssl', action='store_true', help='Use ssl to connect to elasticsearch')
    parser.add_argument('--es-index', default='charitysearch', help='index used to store charity data')
    parser.add_argument('--es-type', default='charity', help='type used to store charity data')

    args = parser.parse_args()

    app.config["es"] = Elasticsearch(
        host=args.es_host,
        port=args.es_port,
        url_prefix=args.es_url_prefix,
        use_ssl=args.es_use_ssl
    )
    app.config["es_index"] = args.es_index
    app.config["es_type"] = args.es_type

    bottle.debug(args.debug)

    bottle.run(app, server=args.server, host=args.host, port=args.port, reloader=args.debug)
项目:Pardus-Bulut    作者:ferhatacikalin    | 项目源码 | 文件源码
def run():
    import bottle

    bottle.debug(True)
    vlevel = 2 if 'verbose' in sys.argv else 0
    result = unittest.TextTestRunner(verbosity=vlevel).run(suite)

    sys.exit((result.errors or result.failures) and 1 or 0)
项目:bottle-react    作者:keredson    | 项目源码 | 文件源码
def run():
  bottle.debug(not PROD)
  bottle.run(
    app=app, 
    host='localhost',
    port='2081',
    reloader=not PROD
  )
项目:memex-dossier-open    作者:dossier    | 项目源码 | 文件源码
def main():
    args, app = get_application()
    app.run(server='wsgiref', host=args.host, port=args.port,
            debug=args.bottle_debug, reloader=args.reload)
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def start(browser=False, debug=False):
    """ Start a bottle web server.
        Derived from WSGIRefServer.run()
        to have control over the main loop.
    """
    global DEBUG
    DEBUG = debug

    class FixedHandler(wsgiref.simple_server.WSGIRequestHandler):
        def address_string(self): # Prevent reverse DNS lookups please.
            return self.client_address[0]
        def log_request(*args, **kw):
            if debug:
                return wsgiref.simple_server.WSGIRequestHandler.log_request(*args, **kw)

    S.server = wsgiref.simple_server.make_server(
        conf['network_host'],
        conf['network_port'],
        bottle.default_app(),
        wsgiref.simple_server.WSGIServer,
        FixedHandler
    )
    S.server.timeout = 0.01
    S.server.quiet = not debug
    if debug:
        bottle.debug(True)
    print "Internal storage root is: " + conf['rootdir']
    print "Persistent storage root is: " + conf['stordir']
    print "-----------------------------------------------------------------------------"
    print "Starting server at http://%s:%d/" % ('127.0.0.1', conf['network_port'])
    print "-----------------------------------------------------------------------------"
    driveboard.connect_withfind()
    # open web-browser
    if browser:
        try:
            webbrowser.open_new_tab('http://127.0.0.1:'+str(conf['network_port']))
        except webbrowser.Error:
            print "Cannot open Webbrowser, please do so manually."
    sys.stdout.flush()  # make sure everything gets flushed
    # start server
    print "INFO: Starting web server thread."
    S.start()