add NI
This commit is contained in:
3
app.py
3
app.py
@@ -4,6 +4,7 @@ GeoIP Ban Generator - Web Application
|
|||||||
|
|
||||||
from flask import Flask, render_template, request, Response, jsonify
|
from flask import Flask, render_template, request, Response, jsonify
|
||||||
from geoip_handler import GeoIPHandler
|
from geoip_handler import GeoIPHandler
|
||||||
|
from flask import jsonify, render_template, request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -116,7 +117,7 @@ def inject_globals():
|
|||||||
'redis_connected': redis_cache.health_check()['connected'] if redis_cache else False,
|
'redis_connected': redis_cache.health_check()['connected'] if redis_cache else False,
|
||||||
}
|
}
|
||||||
|
|
||||||
from flask import jsonify, render_template, request
|
|
||||||
|
|
||||||
def _wants_json():
|
def _wants_json():
|
||||||
if request.path.startswith("/api/"):
|
if request.path.startswith("/api/"):
|
||||||
|
|||||||
@@ -189,6 +189,8 @@ COMMON_COUNTRIES = [
|
|||||||
{'code': 'EC', 'name': 'Ecuador'},
|
{'code': 'EC', 'name': 'Ecuador'},
|
||||||
{'code': 'BO', 'name': 'Bolivia'},
|
{'code': 'BO', 'name': 'Bolivia'},
|
||||||
{'code': 'PY', 'name': 'Paraguay'},
|
{'code': 'PY', 'name': 'Paraguay'},
|
||||||
|
{'code': 'NI', 'name': 'Nicaragua'},
|
||||||
|
|
||||||
|
|
||||||
# Caribbean
|
# Caribbean
|
||||||
{'code': 'CU', 'name': 'Cuba'},
|
{'code': 'CU', 'name': 'Cuba'},
|
||||||
|
|||||||
13
script.py
13
script.py
@@ -4,17 +4,18 @@ import re
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
BASE_URL = "http://geo-block.krk.itg.demo-ht.iadm"
|
BASE_URL = "http://geo-block.krk.itg.demo-ht.iadm"
|
||||||
ENDPOINT = "/api/generate"
|
ENDPOINT = "/api/generate/raw"
|
||||||
|
|
||||||
payload = {
|
payload_json = """{
|
||||||
"countries": [
|
"countries": [
|
||||||
"PL"
|
"PL"
|
||||||
],
|
],
|
||||||
"aggregate": true,
|
"aggregate": true,
|
||||||
"use_cache": true,
|
"use_cache": true,
|
||||||
"app_type": "haproxy",
|
"app_type": "raw-cidr_json",
|
||||||
"app_variant": "map"
|
"as_js": false
|
||||||
}
|
}"""
|
||||||
|
payload = json.loads(payload_json)
|
||||||
|
|
||||||
resp = requests.post(BASE_URL + ENDPOINT, json=payload, timeout=120)
|
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()
|
ct = (resp.headers.get("Content-Type") or "").lower()
|
||||||
|
|
||||||
if resp.status_code >= 400:
|
if resp.status_code >= 400:
|
||||||
# try show JSON error, else text
|
|
||||||
try:
|
try:
|
||||||
print(json.dumps(resp.json(), indent=2))
|
print(json.dumps(resp.json(), indent=2))
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -42,7 +42,6 @@ else:
|
|||||||
if m:
|
if m:
|
||||||
filename = m.group(1)
|
filename = m.group(1)
|
||||||
else:
|
else:
|
||||||
# fallback extension
|
|
||||||
if "text/csv" in ct:
|
if "text/csv" in ct:
|
||||||
filename += ".csv"
|
filename += ".csv"
|
||||||
elif "javascript" in ct:
|
elif "javascript" in ct:
|
||||||
|
|||||||
Reference in New Issue
Block a user