add NI
This commit is contained in:
13
script.py
13
script.py
@@ -4,17 +4,18 @@ import re
|
||||
import requests
|
||||
|
||||
BASE_URL = "http://geo-block.krk.itg.demo-ht.iadm"
|
||||
ENDPOINT = "/api/generate"
|
||||
ENDPOINT = "/api/generate/raw"
|
||||
|
||||
payload = {
|
||||
payload_json = """{
|
||||
"countries": [
|
||||
"PL"
|
||||
],
|
||||
"aggregate": true,
|
||||
"use_cache": true,
|
||||
"app_type": "haproxy",
|
||||
"app_variant": "map"
|
||||
}
|
||||
"app_type": "raw-cidr_json",
|
||||
"as_js": false
|
||||
}"""
|
||||
payload = json.loads(payload_json)
|
||||
|
||||
resp = requests.post(BASE_URL + ENDPOINT, json=payload, timeout=120)
|
||||
|
||||
@@ -26,7 +27,6 @@ print("X-Generated-At:", resp.headers.get("X-Generated-At"))
|
||||
ct = (resp.headers.get("Content-Type") or "").lower()
|
||||
|
||||
if resp.status_code >= 400:
|
||||
# try show JSON error, else text
|
||||
try:
|
||||
print(json.dumps(resp.json(), indent=2))
|
||||
except Exception:
|
||||
@@ -42,7 +42,6 @@ else:
|
||||
if m:
|
||||
filename = m.group(1)
|
||||
else:
|
||||
# fallback extension
|
||||
if "text/csv" in ct:
|
||||
filename += ".csv"
|
||||
elif "javascript" in ct:
|
||||
|
||||
Reference in New Issue
Block a user