Skip to content
This repository was archived by the owner on Aug 21, 2018. It is now read-only.

Commit be62b81

Browse files
committed
new code
1 parent c729fd2 commit be62b81

3 files changed

Lines changed: 66 additions & 3 deletions

File tree

module04/lab04-learning-python-json/loops_ex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
for hungry in donut["flavors"]["flavor"]:
1111
print(hungry["id"] + " " + hungry["type"])
1212
print()
13-
1413

15-
cars={"sports":{"porsche":"Volkswagon","Viper":"Dodge","Corvette":"Chevy"}}
14+
15+
cars={"sports":{"Porsche":"Volkswagon","Viper":"Dodge","Corvette":"Chevy"}}
1616
#Parse JSON without loops
17-
print("porsche " + cars["sports"]["porsche"])
17+
print("Porsche " + cars["sports"]["Porsche"])
1818
print("Viper " + cars["sports"]["Viper"])
1919
print("Corvette " + cars["sports"]["Corvette"])
2020
print()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
rooms={
3+
"items": [
4+
{
5+
"id": "Y2lzY29zcGFyazovL300vNDM5YmNiZTAtNTI5NC0xMWU2LWExMTEtMTdlMWMwMDI4ZmIy",
6+
"type": "group",
7+
"created": "2016-07-25T18:19:02.542Z",
8+
"isLocked": False,
9+
"teamId": "Y2lzY29zcGFyazovvNDZlMmFjZDAtMjBlYy0xMWU2LTg5NTItNWJkZTQwMjVmZDVm",
10+
"title": "GSX Mini Hacks",
11+
"lastActivity": "2016-08-09T19:02:45.199Z"
12+
},
13+
{
14+
"id": "Y2lzY29zcGFyazovL00vYzNjOTU1NDAtNDc3Yi0xMWU2LWEwYmYtYTc2NTNjNWQwZTMw",
15+
"type": "group",
16+
"created": "2016-07-11T15:25:57.268Z",
17+
"isLocked": False,
18+
"title": "CLUS16 - Learning Labs",
19+
"lastActivity": "2016-07-14T21:52:24.432Z"
20+
},
21+
{
22+
"id": "Y2lzY29zcGFyazovL3VzL1JPTvNzAxNjQ0YjAtMjFkZi0xMWU2LWJhMjgtNjU2ZWJlYjhjNjY5",
23+
"type": "group",
24+
"created": "2016-05-24T18:43:42.352Z",
25+
"isLocked": False,
26+
"teamId": "Y2lzY29zcGFyazovL3VFQU0vNDZlMmFjZDAtMjBlYy0xMWU2LTg5NTItNWJkZTQwMjVmZDVm",
27+
"title": "GSX 2016",
28+
"lastActivity": "2016-08-06T01:02:14.597Z"
29+
},
30+
{
31+
"id": "Y2lzY29zcGFyazovL3VzL1J0vYjlhMTkyODAtMjBmYy0xMWU2LWFjNzQtMmQ5ZmRhMmUxOTE5",
32+
"type": "group",
33+
"created": "2016-05-23T15:40:49.973Z",
34+
"isLocked": False,
35+
"teamId": "Y2lzY29zcGFyazovL3VFQU0vNDY3NzJkMTAtZGE1Yy0xMWU1LWE0ODEtM2JjOGYyNDIzOGI5",
36+
"title": "Coding Classes",
37+
"lastActivity": "2016-06-01T15:05:18.060Z"
38+
}
39+
]
40+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import json
2+
import requests
3+
4+
accessToken = "ZjU1ZWEyNWMtYjI0MC00NGI5LTgyM2UtN2FlNmQzOWU5NjlhMzRiZmJlMDYtYzcx" #put your access token here between the quotes.
5+
6+
7+
def setHeaders():
8+
accessToken_hdr = 'Bearer ' + accessToken
9+
spark_header = {'Authorization': accessToken_hdr, 'Content-Type': 'application/json; charset=utf-8'}
10+
return spark_header
11+
12+
13+
def getRooms(theHeader):
14+
uri = 'https://api.ciscospark.com/v1/rooms'
15+
resp = requests.get(uri, headers=theHeader)
16+
print("SparkAPI: ")
17+
return resp.json()
18+
19+
20+
header=setHeaders()
21+
value=getRooms(header)
22+
print (json.dumps(value, indent=4, separators=(',', ': ')))
23+
print(value)

0 commit comments

Comments
 (0)