예제 #1
0
 def delete(self,path):
     if self.auth is None:
         try:
             url = self.firebase+path+'.json?print=pretty'
             response = urequests.delete(url).json()
             return response
         except:
             print("erro")
     else:
         try:
             url =self.firebase+path+'.json?auth='+self.auth
             response = urequests.delete(url)
             return response
         except:
             print("erro")
예제 #2
0
def delete_station(api_key, station_id):
    """HTTP 204 if successful"""
    url = "http://api.openweathermap.org/data/3.0/stations"
    url += "/{}".format(station_id)
    url += "?appid={}".format(api_key)
    response = urequests.delete(url)
    return response
def deleteResource(url, login):
    body = {}

    header = {'X-M2M-Origin': login, 'Content-Type': 'application/json'}

    r = urequests.delete(url, data=json.dumps(body), headers=header)
    return r.status_code, r.text, r
예제 #4
0
 def delete(self, path):
     try:
         url = self.firebase + path + '.json?print=pretty' if self.auth == None else self.firebase + path + '.json?auth=' + self.auth
         response = urequests.delete(url).json()
         return response
     except:
         print("DELETE Error?")
예제 #5
0
 def delete_datapoint(self,
                      stream_id,
                      start_time=None,
                      end_time=None,
                      headers=None):
     headers = self.set_headers(headers)
     response = urequests.delete(STREAMS_URI + "history/" + stream_id,
                                 params={
                                     "start_time": start_time,
                                     "end_time": end_time
                                 },
                                 headers=headers)
     return self.check_response_code(response)
예제 #6
0
def Delete_AT(Table, ID):
    urlBase, headers = AT_setup()
    urlValue = urlBase + secrets.ATdocID + "/" + quote(
        Table) + "?" + "records[]=" + quote(ID)
    print(urlValue)
    try:
        value = urequests.delete(urlValue, headers=headers).text
        data = ujson.loads(value)
        print(data)
        result = data.get("records")[-1].get("deleted")
    except Exception as e:
        print(e)
        result = 'failed'
    return result
예제 #7
0
 def __call__(self, *args, **kwargs):
     url = self.url
     for a in args:
         url += "/" + str(a)
     http_method = kwargs.pop('http_method',
                              'get' if not kwargs else 'put').lower()
     if http_method == 'put':
         r = requests.put(url, data=json.dumps(kwargs))
     elif http_method == 'post':
         r = requests.post(url, data=json.dumps(kwargs))
     elif http_method == 'delete':
         r = requests.delete(url)
     else:
         r = requests.get(url)
     if r.status_code != 200:
         raise QhueException("Received response {c} from {u}".format(
             c=r.status_code, u=url))
     resp = r.json()
     if type(resp) == list:
         errors = [m['error']['description'] for m in resp if 'error' in m]
         if errors:
             raise QhueException("\n".join(errors))
     return resp
예제 #8
0
 def delete_datastream(self, stream_id, headers=None):
     headers = self.set_headers(headers)
     response = urequests.delete(STREAMS_URI + "inventory/" + stream_id,
                                 headers=headers)
     return self.check_response_code(response)
예제 #9
0
 def delete(self, path, **kwargs):
     headers = self._prepare_headers(self._token_header)
     response = urequests.delete(self.base_url + path,
                                 headers=headers,
                                 **kwargs)
     return response
예제 #10
0
import urequests
respuesta = urequests.get('https://httpbin.org/get')
print(respuesta.text)
print(respuesta.json())
print(respuesta.status_code)
print(respuesta.reason)
respuesta = urequests.post('https://httpbin.org/post', data="micropython")
print(respuesta.text)
respuesta = urequests.delete('https://httpbin.org/delete',
                             data="compilar para probar")
print(respuesta.text)
respuesta = urequests.put('https://httpbin.org/put', data="IoT fácil")
print(respuesta.text)
예제 #11
0
def del_db(base_url, db, headers={}):
    return r.delete("{}/{}".format(base_url, db), headers=headers).json()