當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。