aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/main.py5
-rw-r--r--app/util/log.py8
2 files changed, 6 insertions, 7 deletions
diff --git a/app/main.py b/app/main.py
index 266c589..78a65c8 100644
--- a/app/main.py
+++ b/app/main.py
@@ -15,7 +15,6 @@ import random
from models import User, Link
from database import *
from app.util.log import log
-from config import BASE_URL
class FlaskUser(UserMixin):
@@ -158,14 +157,14 @@ def log_redirect(link: str):
link = link.upper()
# If `link` is not exactly 5 characters, return redirect to base url
if len(link) != 5:
- return redirect(BASE_URL)
+ return redirect(url_for("login"))
# Make sure the link exists in the database
db = SessionLocal()
link_record = db.query(Link).filter(Link.link == link).first()
if not link_record:
db.close()
- return redirect(BASE_URL)
+ return redirect(url_for("login"))
else:
# Log the visit
if request.headers.get("X-Real-IP"):
diff --git a/app/util/log.py b/app/util/log.py
index 943863d..6be82e7 100644
--- a/app/util/log.py
+++ b/app/util/log.py
@@ -4,10 +4,10 @@ from ua_parser import user_agent_parser
from ip2locationio.ipgeolocation import IP2LocationIOAPIError
from database import SessionLocal
-from config import LOG, API_KEY, IP_TO_LOCATION
+import config
from models import Link, Record
-configuration = ip2locationio.Configuration(API_KEY)
+configuration = ip2locationio.Configuration(config.API_KEY)
ipgeolocation = ip2locationio.IPGeolocation(configuration)
"""
@@ -25,7 +25,7 @@ def log(link, ip, user_agent):
.first()
)
- if IP_TO_LOCATION:
+ if config.IP_TO_LOCATION:
# Get IP to GEO via IP2Location.io
try:
data = ipgeolocation.lookup(ip)
@@ -33,7 +33,7 @@ def log(link, ip, user_agent):
isp = data["as"]
# Fatal error, API key is invalid or out of requests, quit
except IP2LocationIOAPIError:
- LOG.error(
+ config.LOG.error(
"Invalid API key or insufficient credits. Change the"
" `config.ini` file if you no longer need IP geolocation."
)