From: Roland Häder Date: Tue, 23 May 2023 04:05:26 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8300193069511e1d8ba278ac6b940c91da4434f3;p=fba.git Continued: - proper URLs with base_url - all JSON replies now start with /api/ --- diff --git a/api.py b/api.py index 897c269..0174a8d 100644 --- a/api.py +++ b/api.py @@ -12,7 +12,7 @@ import fba app = FastAPI(docs_url=fba.config["base_url"] + "/docs", redoc_url=fba.config["base_url"] + "/redoc") templates = Jinja2Templates(directory=".") -@app.get(fba.config["base_url"] + "/info") +@app.get(fba.config["base_url"] + "/api/info") def info(): fba.cursor.execute("SELECT (SELECT COUNT(domain) FROM instances), (SELECT COUNT(domain) FROM instances WHERE software IN ('pleroma', 'mastodon', 'misskey', 'gotosocial', 'friendica', 'bookwyrm', 'takahe')), (SELECT COUNT(blocker) FROM blocks), (SELECT COUNT(domain) FROM instances WHERE last_status_code IS NOT NULL)") known, indexed, blocks, errorous = fba.cursor.fetchone() @@ -25,7 +25,7 @@ def info(): "slogan" : fba.config["slogan"] } -@app.get(fba.config["base_url"] + "/top") +@app.get(fba.config["base_url"] + "/api/top") def top(blocked: int = None, blockers: int = None, reference: int = None, software: int = None): if blocked != None: if blocked > 500: @@ -98,13 +98,13 @@ def index(request: Request, blockers: int = None, blocked: int = None, reference scores = None if blockers != None and blockers > 0: - res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blockers={blockers}") + res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api/top?blockers={blockers}") elif blocked != None and blocked > 0: - res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?blocked={blocked}") + res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api/top?blocked={blocked}") elif reference != None and reference > 0: - res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?reference={reference}") + res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api/top?reference={reference}") elif software != None and software > 0: - res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/top?software={software}") + res = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api/top?software={software}") else: raise HTTPException(status_code=400, detail="No filter specified") @@ -133,7 +133,7 @@ def index(request: Request, domain: str = None, reason: str = None, reverse: str blocks = None if domain == None and reason == None and reverse == None: - info = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/info") + info = requests.get(f"http://127.0.0.1:{fba.config['port']}{fba.config['base_url']}/api/info") if not info.ok: raise HTTPException(status_code=info.status_code, detail=info.text) diff --git a/index.html b/index.html index 4ba3413..7ac1bdf 100644 --- a/index.html +++ b/index.html @@ -99,9 +99,9 @@ {{loop.index}} {% if software %} - {{entry['domain']}} + {{entry['domain']}} {% else %} - {{entry['domain']}}  + {{entry['domain']}}  ↗ {% endif %} @@ -131,11 +131,11 @@ {{block['blocker']}} - {% if reason or domain %}↘{% endif %} + {% if reason or domain %}↘{% endif %} {{block['blocked']}} - {% if reason or reverse %}↘{% endif %} + {% if reason or reverse %}↘{% endif %} {{block['reason']}} {{block['first_added']}} @@ -162,10 +162,10 @@

- top 50 defederating / - defederated instances / - referencing instances / - used software + top 50 defederating / + defederated instances / + referencing instances / + used software

known instances: {{info.known_instances}}