fixed bug when domain is empty

This commit is contained in:
Enju Aihara 2022-04-22 20:42:39 +02:00
parent b28453a083
commit 80b9cba5f3
2 changed files with 4 additions and 2 deletions

4
api.py
View file

@ -1,4 +1,4 @@
from fastapi import FastAPI, Request, HTTPException from fastapi import FastAPI, Request, HTTPException, responses
import sqlite3 import sqlite3
from hashlib import sha256 from hashlib import sha256
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
@ -55,6 +55,8 @@ def blocked(domain: str = None):
@app.get(base_url+"/") @app.get(base_url+"/")
def index(request: Request, domain: str = None): def index(request: Request, domain: str = None):
if domain == "":
return responses.RedirectResponse("/")
blocks = get(f"http://127.0.0.1:8069{base_url}/api?domain={domain}") blocks = get(f"http://127.0.0.1:8069{base_url}/api?domain={domain}")
info = None info = None
if domain == None: if domain == None:

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<title>fedi-block-api {{domain}}</title> <title>fedi-block-api{% if domain %} {{domain}}{% endif %}</title>
<style> <style>
body { body {
background-color: #000022; background-color: #000022;