import uvicorn
import requests
import re
+import validators
+
from fba import *
router = fastapi.FastAPI(docs_url=config.get("base_url") + "/docs", redoc_url=config.get("base_url") + "/redoc")
blocks = None
if domain != None:
+ if not validators.domain(domain):
+ raise HTTPException(status_code=500, detail="Invalid domain")
+
blocks = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/index.json?domain={domain}")
elif reason != None:
blocks = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/index.json?reason={reason}")
elif reverse != None:
+ if not validators.domain(reverse):
+ raise HTTPException(status_code=500, detail="Invalid domain")
+
blocks = requests.get(f"http://{config.get('host')}:{config.get('port')}{config.get('base_url')}/api/index.json?reverse={reverse}")
if blocks != None:
<!DOCTYPE html>
<head>
- <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
+ <title>fedi-block-api{% if domain %} - Instances that block {{domain}}{% elif reverse %} - Instances that are blocked by {{reverse}}{% endif %}</title>
<link rel="alternate" type="application/rss+xml" title="RSS Feed for latest blocked instances" href="{{base_url}}/rss" />
{% if domain %}
<link rel="alternate" type="application/rss+xml" title="RSS Feed for blocked domain {{domain}}" href="{{base_url}}/rss?domain={{domain}}" />
}
.block_level {
background-color: #1c1c3c;
- width: 80em;
- padding: 5px;
+ width: 100%;
margin: auto;
margin-top: 10px;
}