-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep2.py
More file actions
37 lines (24 loc) · 1.02 KB
/
step2.py
File metadata and controls
37 lines (24 loc) · 1.02 KB
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
##The first one is straightforward. You’re going to reverse a string.
##That is, if the API says “cupcake,” you’re going to send back “ekacpuc.”
##POST a JSON dictionary with the key token and your token value to this endpoint:
##http://challenge.code2040.org/api/reverse
##This endpoint will return a string that your code should then reverse, as in the example above.
##Once that string is reversed, send it back to us. POST some JSON to:
##http://challenge.code2040.org/api/reverse/validate
##Use the token for your token.
##Use the key string for your reversed string./
import requests
token = "dc12b6952158de030df0dea0a4d4b765"
data = {
"token": token
}
url = "http://challenge.code2040.org/api/reverse"
##POSTing the string
response = requests.post(url=url, data=data)
string = response.content
##Reversing the string
reversedString = string[::-1]
data["string"] = reversedString
##POSTing the reversed string
url = "http://challenge.code2040.org/api/reverse/validate"
response = requests.post(url=url, data=data)