Add contact info to service
All checks were successful
Build and Publish / build_and_publish (push) Successful in 31s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 31s
This commit is contained in:
parent
7af49cbb84
commit
c7155cbd65
3 changed files with 16 additions and 2 deletions
|
@ -5,6 +5,9 @@ services:
|
||||||
- "8000:80"
|
- "8000:80"
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgres://elongate:elongate@db:5432/elongate
|
- 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:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
db:
|
db:
|
||||||
|
|
11
src/main.py
11
src/main.py
|
@ -27,6 +27,15 @@ except FileNotFoundError:
|
||||||
WORDS = []
|
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
|
@asynccontextmanager
|
||||||
async def lifespan(_app: FastAPI):
|
async def lifespan(_app: FastAPI):
|
||||||
if os.path.exists("./data"):
|
if os.path.exists("./data"):
|
||||||
|
@ -43,7 +52,7 @@ async def lifespan(_app: FastAPI):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI(lifespan=lifespan)
|
app = FastAPI(lifespan=lifespan, contact=get_contact_details())
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,9 @@
|
||||||
<h1>Create redirect</h1>
|
<h1>Create redirect</h1>
|
||||||
<p>Link shorteners? nah. Link Elongater. Make your URLs really long.</p>
|
<p>Link shorteners? nah. Link Elongater. Make your URLs really long.</p>
|
||||||
<p>
|
<p>
|
||||||
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 <a href="/docs">API Documentation</a>).
|
||||||
</p>
|
</p>
|
||||||
<br/>
|
<br/>
|
||||||
<form>
|
<form>
|
||||||
|
|
Loading…
Reference in a new issue