How to use the bottle.run function in bottle

To help you get started, we’ve selected a few bottle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sametmax / 0bin / zerobin / cmd.py View on Github external
settings.HOST = host or settings.HOST
    settings.PORT = port or settings.PORT
    settings.USER = user or settings.USER
    settings.GROUP = group or settings.GROUP
    settings.PASTE_ID_LENGTH = paste_id_length or settings.PASTE_ID_LENGTH

    try:
        _, app = get_app(debug, settings_file, compressed_static, settings=settings)
    except SettingsValidationError as err:
        print('Configuration error: %s' % err.message, file=sys.stderr)
        sys.exit(1)

    thread.start_new_thread(drop_privileges, (settings.USER, settings.GROUP))

    if settings.DEBUG:
        run(app, host=settings.HOST, port=settings.PORT, reloader=True,
            server="cherrypy")
    else:
        run(app, host=settings.HOST, port=settings.PORT, server="cherrypy")
github KBNLresearch / frame-generator / frame-generator / web.py View on Github external
result = json.dumps(data)

    except Exception as e:
        result = json.dumps({'error': repr(e)})

    finally:
        if 'input_dir' in locals():
            if os.path.isdir(input_dir):
                shutil.rmtree(input_dir)

    print result
    return result

if __name__ == '__main__':
    run(host='localhost', port=8091)
github marlboromoo / willie-lumberjack / web.py View on Github external
def run(dev=False):
    """Start the Bottle server.

    :dev: True if development else False

    """
    debug, reloader = False, False
    if dev:
        debug, reloader = True, True
    monkey.patch_all()
    bottle.run(
        app=app, host=config.BIND_HOST, port=config.BIND_PORT,
        server='geventSocketIO',
        debug=debug, reloader=reloader)
github oVirt / ovirt-node / src / ovirt / node / tools / features.py View on Github external
    @app.route("/")
    def index():
        """Show the complete registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        return xmlbuilder.build(registry)

    @app.route("/methods/")
    def call_method(path):
        """Call some method offered by the registry
        """
        bottle.response.headers['Content-Type'] = 'application/xml'
        kwargs = dict(bottle.request.query.items())
        return xmlbuilder.build(registry.methods[path](**kwargs))

    bottle.run(app, host='0.0.0.0', port=8082, reloader=True, debug=True)
github piku / piku / examples / python / main.py View on Github external
table.append('')
    result['req_data'] = '\n'.join(table)
    return result

@route("/")
def static(path):
    return static_file(path, root="static")

app = default_app()

if __name__ == '__main__':
    log.debug("Beginning run.")
    HTTP_PORT = int(environ.get('PORT', 8000))
    BIND_ADDRESS = environ.get('BIND_ADDRESS', '127.0.0.1')
    DEBUG = 'true' == environ.get('DEBUG', 'false').lower()
    run(host=BIND_ADDRESS, port=HTTP_PORT, debug=DEBUG)
github square / connect-api-examples / connect-examples / oauth / python / oauth-flow.py View on Github external
# Here, instead of printing the access token, your application server should store it securely
      # and use it in subsequent requests to the Connect API on behalf of the merchant.
      print ('Access token: ' + response.access_token)
      return 'Authorization succeeded!'

    # The response from the Obtain Token endpoint did not include an access token. Something went wrong.
    else:
      return 'Code exchange failed!'

  # The request to the Redirect URL did not include an authorization code. Something went wrong.
  else:
    return 'Authorization failed!'

# Start up the server
run(host='localhost', port=8080)
github fetchai / ledger / apps / swarm / monitoring / server.py View on Github external
context = {}

    root = bottle.Bottle()
    root.route('/static/', method='GET', callback=functools.partial(get_static))
    root.route('/data', method='GET', callback=functools.partial(get_data, context))
    root.route('/', method='GET', callback=functools.partial(get_slash))

    with contextlib.closing(Monitoring()) as myMonitoring:
        root.route('/network', method='GET', callback=functools.partial(get_data2, context, myMonitoring))
        root.route('/chain', method='GET', callback=functools.partial(get_chain_data, context, myMonitoring))
        root.route('/chain2', method='GET', callback=functools.partial(get_chain_data2, context, myMonitoring))
        if g_ssl:
            from utils import SSLWSGIRefServer
            srv = SSLWSGIRefServer.SSLWSGIRefServer(host="0.0.0.0", port=g_port)
            bottle.run(server=srv, app=root)
        else:
            bottle.run(app=root, host='0.0.0.0', port=g_port)
github sjjf / md_server / mdserver / server.py View on Github external
route(md_base + '/meta-data/', 'GET', mdh.gen_metadata)
        route(md_base + '/user-data', 'GET', mdh.gen_userdata)
        route(md_base + '/meta-data/hostname', 'GET', mdh.gen_hostname)
        route(md_base + '/meta-data/instance-id', 'GET', mdh.gen_instance_id)
        route(md_base + '/meta-data/public-keys/', 'GET', mdh.gen_public_keys)
        route(md_base + '/meta-data/public-keys//', 'GET',
              mdh.gen_public_key_dir)
        route((md_base + '/meta-data/public-keys//openssh-key'), 'GET',
              mdh.gen_public_key_file)

    # support for uploading instance data
    route('/instance-upload', 'POST', mdh.instance_upload)

    svr_port = app.config.get('mdserver.port')
    listen_addr = app.config.get('mdserver.listen_address')
    run(host=listen_addr, port=svr_port)
github kalyan02 / tumblrthemr / src / server.py View on Github external
def start( path=PROJECTS_DIRECTORY, port=8080 ):
	global PROJECTS_DIRECTORY
	PROJECTS_DIRECTORY = path
	print "DO START (%s,%s)" % (path,port);
	bottle.debug()
	bottle.run( app, host='localhost', port=port, reloader=False )
github locaweb / simplenet / src / server.py View on Github external
def main():
    os.setgid(grp.getgrnam('nogroup')[2])
    os.setuid(pwd.getpwnam(config.get("server", "user"))[2])
    debug(config.getboolean("server", "debug"))
    port = config.getint("server", "port")
    bind_addr = config.get("server", "bind_addr")
    set_logger()
    LOG.info("Starting Simplestack server")
    run(host=bind_addr, port=port, server="gevent")