From c7155cbd65e87a0901cff832578d871e0c00af9e Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Thu, 11 Jul 2024 17:57:01 +0100 Subject: [PATCH] Add contact info to service --- docker-compose.yml | 3 +++ src/main.py | 11 ++++++++++- src/static/index.html | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 58e9df1..2be79f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,9 @@ services: - "8000:80" environment: - DATABASE_URL=postgres://elongate:elongate@db:5432/elongate + #- CONTACT_NAME=Your Name Here + #- CONTACT_EMAIL=your@email.example + #- CONTACT_URL=https://your.website.example/contact depends_on: - db db: diff --git a/src/main.py b/src/main.py index 4960941..5d069b3 100644 --- a/src/main.py +++ b/src/main.py @@ -27,6 +27,15 @@ except FileNotFoundError: WORDS = [] +def get_contact_details(): + v = {"name": os.getenv("CONTACT_NAME", "not specified")} + if (email := os.getenv("CONTACT_EMAIL")) is not None: + v["email"] = email + if (url := os.getenv("CONTACT_URL")) is not None: + v["url"] = url + return v + + @asynccontextmanager async def lifespan(_app: FastAPI): if os.path.exists("./data"): @@ -43,7 +52,7 @@ async def lifespan(_app: FastAPI): yield -app = FastAPI(lifespan=lifespan) +app = FastAPI(lifespan=lifespan, contact=get_contact_details()) templates = Jinja2Templates(directory="templates") diff --git a/src/static/index.html b/src/static/index.html index 3818c78..fa71df1 100644 --- a/src/static/index.html +++ b/src/static/index.html @@ -80,7 +80,9 @@

Create redirect

Link shorteners? nah. Link Elongater. Make your URLs really long.

- WARNING: This service is operated out of good faith, please return that good faith. If you find any redirects that are harmful or malicious, please report them to the operator of this service. + WARNING: This service is operated out of good faith, please return that good faith. + If you find any redirects that are harmful or malicious, please report them to the operator of this service + (can be found in the API Documentation).