format = config.get("timestamp_format")
for row in domainlist:
row["first_seen"] = datetime.utcfromtimestamp(row["first_seen"]).strftime(format)
- row["last_updated"] = datetime.utcfromtimestamp(row["last_updated"]).strftime(format)
+ row["last_updated"] = datetime.utcfromtimestamp(row["last_updated"]).strftime(format) if isinstance(row["last_updated"], float) else None
return templates.TemplateResponse("views/list.html", {
"request" : request,
found = 0
blocklist = list()
- if response is not None and response.ok:
+ if response is not None and response.ok and response.status_code >= 300 and len(response.text) > 0:
blocklist = response.json()
format = config.get("timestamp_format")
for block_level in blocklist:
- for block in blocklist[block_level]:
- block["first_seen"] = datetime.utcfromtimestamp(block["first_seen"]).strftime(format)
- block["last_seen"] = datetime.utcfromtimestamp(block["last_seen"]).strftime(format)
+ for row in blocklist[block_level]:
+ row["first_seen"] = datetime.utcfromtimestamp(row["first_seen"]).strftime(format)
+ row["last_seen"] = datetime.utcfromtimestamp(row["last_seen"]).strftime(format) if isinstance(row["last_updated"], float) else None
found = found + 1
return templates.TemplateResponse("views/top.html", {
response = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/domain.json?domain={domain}")
- if not response.ok or response.status_code > 200 or response.text.strip() == "":
+ if not response.ok or response.status_code >= 300 or response.text.strip() == "":
raise HTTPException(status_code=response.status_code, detail=response.reason)
domain_data = response.json()
format = config.get("timestamp_format")
instance = dict()
for key in domain_data.keys():
- if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch"]:
+ if key in ["last_nodeinfo", "last_blocked", "first_seen", "last_updated", "last_instance_fetch"] and isinstance(domain_data, float):
# Timestamps
- instance[key] = datetime.utcfromtimestamp(domain_data[key]).strftime(format) if isinstance(domain_data[key], float) else "-"
+ instance[key] = datetime.utcfromtimestamp(domain_data[key]).strftime(format)
else:
# Generic
instance[key] = domain_data[key]