예제 #1
0
 def get(self, path, **kwargs):
     '''
     get请求
     :param path: 请求的资源路径
     :param kwargs: 其他附加的HTTP参数列表(如header等)
     :return: response对象
     '''
     return requests.request(
         method='get',
         url=config.generate_api_url(path),
         headers=self._get_header,
         **kwargs
     )
예제 #2
0
 def _post(self, path, data=None, method='post', **kwargs):
     '''
     post, put, deleta等公用的内部方法
     '''
     post_data = data
     if post_data is not None:
         post_data = json.dumps(post_data)
     return requests.request(
         method=method,
         url=config.generate_api_url(path),
         data=post_data,
         headers=self._post_header,
         **kwargs
     )