diff --git a/.env.example b/.env.example
index 0e121e4..aa48810 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,6 @@
+NAME=Krll
+HOST=https://krll.me
+
POSTGRES_HOST=db:5432
POSTGRES_DATABASE=postgres
POSTGRES_USER=postgres
diff --git a/main.py b/main.py
index 44feff2..9732edf 100644
--- a/main.py
+++ b/main.py
@@ -8,6 +8,11 @@ from src.database import engine
from src import models
from src.routes.url import url_route
+from src.env import NAME, HOST
+
+
+DEFAULT_CONTEXT = { "name": NAME, "host": HOST }
+
models.Base.metadata.create_all(bind=engine)
@@ -32,12 +37,20 @@ app.mount("/static", StaticFiles(directory="./static"), name="static")
@app.get("/", response_class=HTMLResponse)
def index(request: Request):
- return templates.TemplateResponse(request=request, name="index.html")
+ return templates.TemplateResponse(
+ request=request,
+ name="index.html",
+ context=DEFAULT_CONTEXT
+ )
@app.get("/about", response_class=HTMLResponse)
def about(request: Request):
- return templates.TemplateResponse(request=request, name="about.html")
+ return templates.TemplateResponse(
+ request=request,
+ name="about.html",
+ context=DEFAULT_CONTEXT
+ )
app.include_router(url_route.routes)
diff --git a/src/env.py b/src/env.py
index 7242d23..d88eb34 100644
--- a/src/env.py
+++ b/src/env.py
@@ -4,6 +4,9 @@ import os
load_dotenv()
+NAME = os.environ.get("NAME")
+HOST = os.environ.get("HOST")
+
POSTGRES_DATABASE = os.environ.get("POSTGRES_DATABASE")
POSTGRES_USER = os.environ.get("POSTGRES_USER")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD")
diff --git a/static/script.js b/static/script.js
index d739802..d716c7f 100644
--- a/static/script.js
+++ b/static/script.js
@@ -45,7 +45,7 @@ const shorten = async () => {
}
const data = await response.json();
- const result = `https://krll.me/${data.key}`
+ const result = `${host}/${data.key}`;
// show the short url
short_url.innerText = result;
diff --git a/templates/index.html b/templates/index.html
index b5aac36..03de80d 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -21,5 +21,9 @@
+
+
{% endblock %}
diff --git a/templates/layout.html b/templates/layout.html
index 08f626d..27b0459 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -14,7 +14,7 @@