-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStage2.py
More file actions
34 lines (23 loc) · 833 Bytes
/
Stage2.py
File metadata and controls
34 lines (23 loc) · 833 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
#Code2040
#Kymberlee Hill
#Stage Two: Haystack
import requests
import json
token = {'token': 'jJ4uV46FdF' }
get_url = 'http://challenge.code2040.org/api/haystack'
send_url = 'http://challenge.code2040.org/api/validateneedle'
accessing_server = requests.post(get_url, data = json.dumps(token))
jsonData = accessing_server.json()
haystack = jsonData['result']['haystack']
needle = jsonData['result']['needle']
print "watch out for the needle:" + " " + needle + " " + "in the given haystack"
length = len(haystack) - 1
for index in xrange(length):
print haystack[index]
if haystack[index] == needle:
location = index
print index
result2 = {'token': 'jJ4uV46FdF', 'needle': location}
second_access2 = requests.post(send_url, data = json.dumps(result2))
challenge_results = second_access2.json()
print(challenge_results)