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


Python request.url方法代码示例

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


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

示例1: handle

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def handle(self, url, method):
        """ Execute the handler bound to the specified url and method and return
        its output. If catchall is true, exceptions are catched and returned as
        HTTPError(500) objects. """
        if not self.serve:
            return HTTPError(503, "Server stopped")

        handler, args = self.match_url(url, method)
        if not handler:
            return HTTPError(404, "Not found:" + url)

        try:
            return handler(**args)
        except HTTPResponse as e:
            return e
        except Exception as e:
            if isinstance(e, (KeyboardInterrupt, SystemExit, MemoryError))\
            or not self.catchall:
                raise
            return HTTPError(500, 'Unhandled exception', e, format_exc(10)) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:22,代码来源:bottle3.py

示例2: copy_ssh_keys_to_servers

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def copy_ssh_keys_to_servers(self, ip, port, payload, sm_args=None):
        servers = self._serverDb.get_server({"id": str(payload["id"])}, detail=True)
        server = servers[0]
        success = self.copy_ssh_keys_to_server(str(server["ip_address"]), str(server["id"]))

        self._smgr_log.log(self._smgr_log.DEBUG, "COPY-KEY: Host: " + server["id"] + " /Status: " + str(success))

        if success and self._provision_immediately_after_reimage == True:
            gevent.spawn(self.gevent_puppet_agent_action, server, self._serverDb, sm_args, "start")
        if success and self.inventory_config_set:
            try:
                url = "http://%s:%s/run_inventory" % (ip, port)
                payload = json.dumps(payload)
                headers = {'content-type': 'application/json'}
                resp = requests.post(url, headers=headers, timeout=5, data=payload)
                return resp.text
            except Exception as e:
                self._smgr_log.log("error", "Error running inventory on  " + str(payload) + " : " + str(e))
                return None 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:21,代码来源:server_mgr_mon_base_plugin.py

示例3: dispatch

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def dispatch(url):
    """
        This class is the beginning of all entrypoints in the Ray API. Here, each url
        will be redirect to the right handler
    """

    url = bottle_req.path
    log.info('request: %s', bottle_req.url)

    if url[-1] == '/':
        url = url[:-1]

    response_code = 200

    try:
        processed = process(url, bottle_req, bottle_resp)

        try:
            from_func, http_status = processed[0], processed[1]
            bottle_resp.status = http_status
            return from_func
        except:
            return processed

    except exceptions.RayException as e:
        log.exception('ray exception: ')
        response_code = e.http_code

    except:
        log.exception('exception:')
        raise

    bottle_resp.status = response_code 
开发者ID:felipevolpone,项目名称:ray,代码行数:35,代码来源:api.py

示例4: __handle_action

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def __handle_action(url):
    # url e.g: /api/user/123/action

    arg = None
    if len(url.split('/')) >= 5:  # indicate that has an id between endpoint and action_name
        arg = http.param_at(url, -2)

    return Action(url, arg, bottle_req).process_action() 
开发者ID:felipevolpone,项目名称:ray,代码行数:10,代码来源:api.py

示例5: handle

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def handle(self, url, method):
        """ Execute the handler bound to the specified url and method and return
        its output. If catchall is true, exceptions are catched and returned as
        HTTPError(500) objects. """
        if not self.serve:
            return HTTPError(503, "Server stopped")

        handler, args = self.match_url(url, method)
        if not handler:
            return HTTPError(404, "Not found:" + url)

        try:
            return handler(**args)
        except HTTPResponse, e:
            return e 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:17,代码来源:bottle2.py

示例6: url

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def url(self):
        """ Full URL as requested by the client (computed).

            This value is constructed out of different environment variables
            and includes scheme, host, port, scriptname, path and query string.
        """
        scheme = self.environ.get('wsgi.url_scheme', 'http')
        host   = self.environ.get('HTTP_X_FORWARDED_HOST', self.environ.get('HTTP_HOST', None))
        if not host:
            host = self.environ.get('SERVER_NAME')
            port = self.environ.get('SERVER_PORT', '80')
            if scheme + port not in ('https443', 'http80'):
                host += ':' + port
        parts = (scheme, host, urlquote(self.fullpath), self.query_string, '')
        return urlunsplit(parts) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:17,代码来源:bottle2.py

示例7: redirect

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def redirect(url, code=303):
    """ Aborts execution and causes a 303 redirect """
    scriptname = request.environ.get('SCRIPT_NAME', '').rstrip('/') + '/'
    location = urljoin(request.url, urljoin(scriptname, url))
    raise HTTPResponse("", status=code, header=dict(Location=location)) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:7,代码来源:bottle2.py

示例8: url

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def url(routename, **kargs):
    return app().get_url(routename, **kargs) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:4,代码来源:bottle3.py

示例9: avatars

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def avatars():
    hashes = set(request.query['hashes'].split(','))
    size = request.query.get('size', 20)
    default = request.query.get('default', 'identicon')
    cls = request.query.get('cls', '.pic-%s')

    response.content_type = 'text/css'
    return '\n'.join((
        '%s {background-image: url(data:image/gif;base64,%s);}'
        % ((cls % h), i.decode())
    ) for h, i in fetch_avatars(hashes, size, default)) 
开发者ID:naspeh,项目名称:mailur,代码行数:13,代码来源:web.py

示例10: proxy

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def proxy():
    url = request.query.get('url')
    if not url:
        return abort(400)

    return proxy_by_nginx(url) 
开发者ID:naspeh,项目名称:mailur,代码行数:8,代码来源:web.py

示例11: redirect

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def redirect(url, code=None):
    if not code:
        code = 303 if request.get('SERVER_PROTOCOL') == 'HTTP/1.1' else 302
    response.status = code
    response.body = ''
    response.set_header('Location', urllib.parse.urljoin(request.url, url))
    return response 
开发者ID:naspeh,项目名称:mailur,代码行数:9,代码来源:web.py

示例12: proxy_by_nginx

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def proxy_by_nginx(url):
    url = '/.proxy?url=%s' % url
    response.set_header('X-Accel-Redirect', url)
    return '' 
开发者ID:naspeh,项目名称:mailur,代码行数:6,代码来源:web.py

示例13: get_request_record

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def get_request_record():
    headers = [[name, value,] for name, value in request.headers.items()]
    is_shellshock_check = is_shellshock(headers)
    
    command, data = None, None
    if is_shellshock_check:
        command, data = perform_commands(headers)

    if public_ip:
        dest_host = public_ip
    else:
        dest_host = urlparse.urlparse(request.url).netloc.split(':',1)[0]

    return {
        'method': request.method,
        'url': request.url,
        'path': request.path,
        'query_string': request.query_string,
        'headers': headers,
        'source_ip': request.environ.get('REMOTE_ADDR'),
        'dest_port': request.environ.get('SERVER_PORT'),
        'dest_host': dest_host,
        'is_shellshock': is_shellshock_check,
        'command': command,
        'command_data': data,
        'timestamp': str(datetime.datetime.now())
    } 
开发者ID:pwnlandia,项目名称:shockpot,代码行数:29,代码来源:shockpot.py

示例14: get_sandesh_url

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def get_sandesh_url(self, ip, introspect_port, uve_name, server_id=None):
        if server_id:
            url = "http://%s:%s/Snh_SandeshUVECacheReq?tname=%s&key=%s" % \
                  (str(ip), str(introspect_port), uve_name, server_id)
        else:
            url = "http://%s:%s/Snh_SandeshUVECacheReq?x=%s" % \
                  (str(ip), str(introspect_port), uve_name)
        return url 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:10,代码来源:server_mgr_mon_base_plugin.py

示例15: validate_rest_api_args

# 需要导入模块: from bottle import request [as 别名]
# 或者: from bottle.request import url [as 别名]
def validate_rest_api_args(self, request, rev_tags_dict):
        ret_data = {"msg": None, "type_msg": None}
        match_keys = list(['id', 'cluster_id', 'tag', 'where'])
        print_match_keys = list(['server_id', 'cluster_id', 'tag', 'where'])
        self._smgr_log.log(self._smgr_log.DEBUG,
                           "Validating bottle arguments.")
        ret_data['status'] = 1
        query_args = parse_qs(urlparse(request.url).query,
                              keep_blank_values=True)
        if len(query_args) == 0:
            ret_data["type"] = ["all"]
            ret_data["status"] = True
            ret_data["match_key"] = None
            ret_data["match_value"] = None
        elif len(query_args) >= 1:
            select_value_list = None
            if "select" in query_args:
                select_value_list = query_args.get("select", None)[0]
                select_value_list = str(select_value_list).split(',')
                self._smgr_log.log(self._smgr_log.DEBUG,
                                   "Select value list=" + str(select_value_list))
                query_args.pop("select")
            if not select_value_list:
                ret_data["type"] = ["all"]
            else:
                ret_data["type"] = select_value_list
            match_key = match_value = None
            if query_args:
                match_key, match_value = query_args.popitem()
            if match_key and match_key not in match_keys:
                ret_data["status"] = False
                ret_data["msg"] = "Wrong Match Key Specified. " + "Choose one of the following keys: " + \
                                  str(['--{0}'.format(key) for key in print_match_keys]).strip('[]')
                self._smgr_log.log(self._smgr_log.ERROR,
                                   "Wrong Match Key")
            elif match_key and (match_value is None or match_value[0] == ''):
                ret_data["status"] = False
                self._smgr_log.log(self._smgr_log.ERROR,
                                   "No macth value given")
                ret_data["msg"] = "No Match Value Specified.\n"
            else:
                ret_data["status"] = True
                if match_key:
                    ret_data["match_key"] = str(match_key)
                else:
                    ret_data["match_key"] = None
                if match_value:
                    ret_data["match_value"] = str(match_value[0])
                else:
                    ret_data["match_value"] = None
        return ret_data 
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:53,代码来源:server_mgr_mon_base_plugin.py


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