@dhruvdutt/

Appbase.io - Python - index

Python 2.7

Insert any JSON object

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.981906877934595","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHJlcXVlc3RzCmltcG9ydCBqc29uCmltcG9ydCBkZW1qc29uCgp1cmwgPSAiaHR0cHM6Ly9zY2Fsci5hcGkuYXBwYmFzZS5pby9ob3VzaW5nLWRlbW8vbGlzdGluZy9IMSIKCnBheWxvYWQgPSBkZW1qc29uLmVuY29kZSh7CiAgIm5hbWUiOiAiVGhlIFdoaXRlIEhvdXNlIiwKICAicm9vbV90eXBlIjogIlByaXZhdGUgcm9vbSIsCiAgInByb3BlcnR5X3R5cGUiOiAiVG93bmhvdXNlIiwKICAicHJpY2UiOiAxMjQsCiAgImhhc19hdmFpbGFiaWxpdHkiOiAidHJ1ZSIsCiAgImFjY29tbW9kYXRlcyI6IDIsCiAgImJlZHJvb21zIjogMSwKICAiYmF0aHJvb21zIjogMS41LAogICJiZWRzIjogMSwKICAiYmVkX3R5cGUiOiAiUmVhbCBCZWQiLAogICJob3N0X2ltYWdlIjogImh0dHBzOi8vYTIubXVzY2FjaGUuY29tL2FjL3BpY3R1cmVzLzdjMjhhMTU1LTNlYjgtNDM4ZC04ZjUxLTQyNmIxOTFhYjc5NS5qcGc/aW50ZXJwb2xhdGlvbj1sYW5jem9zLW5vbmUmY3JvcD13Onc7KiwqJmNyb3A9aDpoOyosKiZyZXNpemU9NTA6KiZvdXRwdXQtZm9ybWF0PWpwZyZvdXRwdXQtcXVhbGl0eT03MCIsCiAgImhvc3RfbmFtZSI6ICJBbHlzb24iLAogICJpbWFnZSI6ICJodHRwczovL2EwLm11c2NhY2hlLmNvbS9pbS9waWN0dXJlcy82ODgzNzc1Mi85NmNhZTRkMV9vcmlnaW5hbC5qcGc/YWtpX3BvbGljeT1tZWRpdW0iLAogICJsaXN0aW5nX3VybCI6ICJodHRwczovL3d3dy5haXJibmIuY29tL3Jvb21zLzUzNjQxMTkiLAogICJsb2NhdGlvbiI6IHsKICAgICAgImxhdCI6IDQ3LjUzNTQwNzMzNzQzOTY3LAogICAgICAibG9uIjogLTEyMi4yNzk4MzA1NzAxNzEyMwogIH0sCiAgImRhdGVfZnJvbSI6IDIwMTcwNDI2LAogICJkYXRlX3RvIjogMjAxNzA0MjEKfSkKCmhlYWRlcnMgPSB7CiAgJ0F1dGhvcml6YXRpb24nOiAiQmFzaWMgV1c1RFoxWjNiM3BXT21VNVpXTTFZMkl3TFRVNFpEZ3ROR0ppTUMxaVlXUmpMV0ZqWVdZM01qWTJOakZtTVE9PSIsCiAgJ0NvbnRlbnQtVHlwZSc6ICJhcHBsaWNhdGlvbi9qc29uIgp9CgpyZXNwb25zZSA9IHJlcXVlc3RzLnJlcXVlc3QoIlBVVCIsIHVybCwgZGF0YT1wYXlsb2FkLCBoZWFkZXJzPWhlYWRlcnMpCgpwYXJzZWQgPSBqc29uLmxvYWRzKHJlc3BvbnNlLnRleHQpCnByaW50IGpzb24uZHVtcHMocGFyc2VkLCBpbmRlbnQ9NCwgc29ydF9rZXlzPVRydWUp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import json
import demjson

url = "https://scalr.api.appbase.io/housing-demo/listing/H1"

payload = demjson.encode({
  "name": "The White House",
  "room_type": "Private room",
  "property_type": "Townhouse",
  "price": 124,
  "has_availability": "true",
  "accommodates": 2,
  "bedrooms": 1,
  "bathrooms": 1.5,
  "beds": 1,
  "bed_type": "Real Bed",
  "host_image": "https://a2.muscache.com/ac/pictures/7c28a155-3eb8-438d-8f51-426b191ab795.jpg?interpolation=lanczos-none&crop=w:w;*,*&crop=h:h;*,*&resize=50:*&output-format=jpg&output-quality=70",
  "host_name": "Alyson",
  "image": "https://a0.muscache.com/im/pictures/68837752/96cae4d1_original.jpg?aki_policy=medium",
  "listing_url": "https://www.airbnb.com/rooms/5364119",
  "location": {
      "lat": 47.53540733743967,
      "lon": -122.27983057017123
  },
  "date_from": 20170426,
  "date_to": 20170421
})

headers = {
  'Authorization': "Basic WW5DZ1Z3b3pWOmU5ZWM1Y2IwLTU4ZDgtNGJiMC1iYWRjLWFjYWY3MjY2NjFmMQ==",
  'Content-Type': "application/json"
}

response = requests.request("PUT", url, data=payload, headers=headers)

parsed = json.loads(response.text)
print json.dumps(parsed, indent=4, sort_keys=True)