aboutsummaryrefslogtreecommitdiff
path: root/app/func
diff options
context:
space:
mode:
Diffstat (limited to 'app/func')
-rw-r--r--app/func/newlink.py17
-rw-r--r--app/func/signup.py2
2 files changed, 5 insertions, 14 deletions
diff --git a/app/func/newlink.py b/app/func/newlink.py
index ec45111..c726499 100644
--- a/app/func/newlink.py
+++ b/app/func/newlink.py
@@ -11,18 +11,9 @@ from db import engine
Generate and return a new randomized link that is connected to the user
Links are composed of 5 uppercase ASCII characters + numbers
"""
-def generate_link(request, owner):
- content_type = request.headers.get('Content-Type')
- if content_type == 'application/json':
- try:
- redirect_link = request.json['redirect_link']
- except KeyError:
- return 'Redirect link not provided', 400
-
- if not validators.url(redirect_link):
- return 'Redirect link is malformed. Please try again', 400
- else:
- return 'Content-Type not supported', 400
+def generate_link(redirect_link, owner):
+ if not validators.url(redirect_link):
+ return None
with engine.begin() as conn:
choices = string.ascii_uppercase + '1234567890'
@@ -36,4 +27,4 @@ def generate_link(request, owner):
except exc.IntegrityError:
continue
- return link, 200
+ return link, expire_date
diff --git a/app/func/signup.py b/app/func/signup.py
index f7c19a2..275a14e 100644
--- a/app/func/signup.py
+++ b/app/func/signup.py
@@ -15,7 +15,7 @@ def generate_account():
while True:
try:
account_string = ''.join(random.choices(string.ascii_uppercase, k=20))
- conn.execute(sqlalchemy.text('INSERT INTO accounts(account_name) VALUES(:account_name)'), [{'account_name': account_string}])
+ conn.execute(sqlalchemy.text('INSERT INTO accounts(api_key) VALUES(:api_key)'), [{'api_key': account_string}])
conn.commit()
break
except exc.IntegrityError: