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


Python HTTPResponse.status_code方法代码示例

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


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

示例1: post

# 需要导入模块: from wheezy.http import HTTPResponse [as 别名]
# 或者: from wheezy.http.HTTPResponse import status_code [as 别名]
    def post(self):

        try:
            form = self.request.form
            code = form["code"][0]
        except:
            return bad_request_with_detail("No data posted, or data in incorrect format")

        params = {"grant_type": "authorization_code", "redirect_uri": config.SPOTIFY_CALLBACK_URL, "code": code}

        token_response = requests.post(config.SPOTIFY_TOKEN_ENDPOINT, data=params, headers=auth_header, verify=True)

        response = HTTPResponse()
        response.content_type = "application/json"
        response.status_code = token_response.status_code

        if token_response.status_code == 200:
            json_response = token_response.json()
            refresh_token = json_response["refresh_token"]
            encrypted_token = crypt.encrypt(refresh_token)
            json_response["refresh_token"] = encrypted_token
            response_body = json.dumps(json_response)
            response.write(response_body)
        else:
            response.write_bytes(token_response.content)

        return response
开发者ID:brki,项目名称:spotify-token-auth-wheezy-web,代码行数:29,代码来源:app.py

示例2: post

# 需要导入模块: from wheezy.http import HTTPResponse [as 别名]
# 或者: from wheezy.http.HTTPResponse import status_code [as 别名]
    def post(self):
        """
        Handle HTTP POST.
        """

        method = self.get_method()
        body = self.get_body()

        # TODO handle method exception.
        result = method(**body)
        payload = self.encoder.encode(result)

        response = HTTPResponse(content_type="application/json")
        response.status_code = 200
        response.write(payload)

        return response
开发者ID:iakinsey,项目名称:unshadow,代码行数:19,代码来源:metric.py

示例3: wrap_request

# 需要导入模块: from wheezy.http import HTTPResponse [as 别名]
# 或者: from wheezy.http.HTTPResponse import status_code [as 别名]
    def wrap_request(self, request, *args, **kwargs):
        '''
        Prepares data and pass control to `restea.Resource` object

        :returns: :class: `wheezy.http.HTTPResponse`
        '''
        data_format, kwargs = self._get_format_name(kwargs)
        formatter = formats.get_formatter(data_format)

        resource = self._resource_class(
            WheezyRequestWrapper(request), formatter
        )
        res, status_code, content_type = resource.dispatch(*args, **kwargs)

        response = HTTPResponse(
            content_type=content_type,
        )
        response.write(res)
        response.status_code = status_code
        return response
开发者ID:kkszysiu,项目名称:restea,代码行数:22,代码来源:wheezywebwrap.py

示例4: _error_response

# 需要导入模块: from wheezy.http import HTTPResponse [as 别名]
# 或者: from wheezy.http.HTTPResponse import status_code [as 别名]
 def _error_response(self, request, error):
     resp = HTTPResponse()
     resp.status_code = ERROR_STATUS_CODE
     resp.write_bytes(json.dumps({'error': error}))
     return resp
开发者ID:sergeyglazyrindev,项目名称:ritcore,代码行数:7,代码来源:decorators.py

示例5: post

# 需要导入模块: from wheezy.http import HTTPResponse [as 别名]
# 或者: from wheezy.http.HTTPResponse import status_code [as 别名]
 def post(self):
     data = self.request.form
     insert(data)
     response = HTTPResponse()
     response.status_code = 201
     return response
开发者ID:prsolucoes,项目名称:benchmarks,代码行数:8,代码来源:main.py


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