Beispiel #1
0
 def postCategory(self, item):
     data = Category(0, self.window.inputName.text())
     headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
     r = requests.post("http://localhost:8080/api/v1/categories",
                       data=data.toJson(),
                       headers=headers)
     print(r.status_code)
     if r.status_code == 200:
         #self.addCategory(Category(**r.json()))
         self.getCategory()
Beispiel #2
0
 def putCategory(self, item):
     data = Category(
         self.view.listview.itemWidget(item).data.id,
         self.window.inputName.text())
     headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
     r = requests.put("http://localhost:8080/api/v1/categories",
                      data=data.toJson(),
                      headers=headers)
     print(r.text)
     if r.status_code == 204:
         self.getCategory()