-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoolbox-file.py
More file actions
25 lines (19 loc) · 822 Bytes
/
toolbox-file.py
File metadata and controls
25 lines (19 loc) · 822 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
# Simple tool run that sends a file over to Toolbox to run a tool
# https://toolbox.nextgis.com/t/kmldae2footprints
import requests
##############SET THESE#######################
token = "YOUR API TOKEN"
tool = "kmldae2footprints"
##############################################
headers = {"Authorization": "Token %s" % token}
filename = "sampledata.zip"
url = "https://toolbox.nextgis.com/api/upload/?format=json&filename=" + filename
files = {}
file = open(filename, "rb")
response = requests.post(url, data=file, headers=headers)
files["zip_with_kmls"] = response.json()
json_request = {"tool": tool, "inputs": {}}
json_request["inputs"]["zip_with_kmls"] = files["zip_with_kmls"]
url = "https://toolbox.nextgis.com/api/tasks/"
response = requests.post(url, json=json_request, headers=headers)
print(response.text)