-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStage4.py
More file actions
38 lines (27 loc) · 1021 Bytes
/
Stage4.py
File metadata and controls
38 lines (27 loc) · 1021 Bytes
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
#Code2040
#Kymberlee Hill
#Stage Four: Dating Game
import requests
import dateutil.parser
import datetime
import iso8601
import json
token = {'token': 'jJ4uV46FdF' }
get_url = 'http://challenge.code2040.org/api/time'
send_url = 'http://challenge.code2040.org/api/validatetime'
accessing_server = requests.post(get_url, data = json.dumps(token))
jsonData = accessing_server.json()
datestamp = jsonData['result']['datestamp']
sec_intervals = jsonData['result']['interval']
converted_sec_intervals = int(sec_intervals)
new_date = iso8601.parse_date(datestamp)
converted_sec_intervals = datetime.timedelta(0, converted_sec_intervals)
date_and_time = new_date + converted_sec_intervals
date_and_time = date_and_time.isoformat()
formated_date = date_and_time.split('+')[0]
formated_date += '.000Z'
print formated_date
result4 = {'token': 'jJ4uV46FdF', 'datestamp': formated_date}
second_access = requests.post(send_url, data = json.dumps(result4))
challenge_results = second_access.json()
print(challenge_results)