-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep3Code2040.py
More file actions
41 lines (30 loc) · 991 Bytes
/
Copy pathstep3Code2040.py
File metadata and controls
41 lines (30 loc) · 991 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
39
40
41
#tier3.py
import requests
import json
#My Token
token = "c3922bf6cf1313e37768687dd70c3b21"
# My Token in a Dictionary
tokens = {"token": token}
# Github Account
repository = "https://github.com/Yeathtsme/code2040"
# Header
header = {'Content-Type': 'application/json'}
# Haystack Link
haystackLink = 'http://challenge.code2040.org/api/haystack'
# Send Here
challenge_endpoint = "http://challenge.code2040.org/api/haystack/validate"
# Calling API's json
response1 = requests.post(haystackLink, data=json.dumps(tokens),headers=header).json()
#print "Response from API: " + response1
needle = response1['needle']
haystack = response1['haystack']
#print(needle)
#print(haystack)
# Find the index of needles within haystack
index = haystack.index(needle)
#print(index)
haystackResult = {"token": token,"needle":index}
# Post Answer Online
response1 = requests.post(challenge_endpoint, data=json.dumps(haystackResult),headers=header)
# Did I Complete Step?
print(response1.text)