Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Dec 13, 2023
1 parent bd65323 commit 217c717
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
15 changes: 7 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Flask==2.3.2
Werkzeug==2.3.4
python-dotenv==1.0.0
Flask-JWT-Extended==4.4.4
flask-restx==1.1.0
psycopg2==2.9.6
SQLAlchemy==1.4.48
qwc-services-core==1.3.20
Flask==3.0.0
Werkzeug==3.0.1
Flask-JWT-Extended==4.6.0
flask-restx==1.3.0
psycopg2==2.9.9
SQLAlchemy==2.0.23
qwc-services-core==1.3.21
23 changes: 14 additions & 9 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def post(self):
attempts = 0
while attempts < 100:
try:
configconn.execute(sql, key=hexdigest, data=datastr, date=date, expires=expires)
configconn.execute(sql, {"key": hexdigest, "data": datastr, "date": date, "expires": expires})
break
except:
pass
Expand All @@ -126,6 +126,7 @@ def post(self):
""".format(table=permalinks_table))
configconn.execute(sql)

configconn.commit()
configconn.close()

# Return
Expand Down Expand Up @@ -156,7 +157,7 @@ def get(self):
WHERE key = :key AND (expires IS NULL OR expires >= CURRENT_DATE)
""".format(table=permalinks_table))
try:
data = json.loads(configconn.execute(sql, key=key).first().data)
data = json.loads(configconn.execute(sql, {"key": key}).mappings().first()["data"])
except:
pass
return jsonify(data)
Expand All @@ -178,7 +179,7 @@ def get(self):
WHERE username = :user
""".format(table=user_permalink_table))
try:
data = json.loads(configconn.execute(sql, user=username).first().data)
data = json.loads(configconn.execute(sql, {"user": username}).mappings().first()["data"])
except:
data = {}
return jsonify(data)
Expand Down Expand Up @@ -224,7 +225,8 @@ def post(self):
SET data = :data, date = :date
""".format(table=user_permalink_table))

conn.execute(sql, user=username, data=datastr, date=date)
conn.execute(sql, {"user": username, "data": datastr, "date": date})
conn.commit()
conn.close()

return jsonify({"success": True})
Expand All @@ -250,7 +252,7 @@ def get(self):
""".format(table=user_bookmark_table, sort_order=sort_order))
try:
data = []
result = conn.execute(sql, user=username)
result = conn.execute(sql, {"user": username}).mappings()
for row in result:
bookmark = {}
bookmark['data'] = json.loads(row.data)
Expand Down Expand Up @@ -310,13 +312,14 @@ def post(self):
attempts = 0
while attempts < 100:
try:
conn.execute(sql, user=username, data=datastr, key=hexdigest, date=date, description=description)
conn.execute(sql, {"user": username, "data": datastr, "key": hexdigest, "date": date, "description": description})
break
except:
pass
hexdigest = hashlib.sha224((datastr + str(random.random())).encode('utf-8')).hexdigest()[0:9]
attempts += 1

conn.commit()
conn.close()

return jsonify({"success": attempts < 100})
Expand All @@ -337,7 +340,7 @@ def get(self, key):
WHERE username = :user and key = :key
""".format(table=user_bookmark_table))
try:
data = json.loads(conn.execute(sql, user=username, key=key).first().data)
data = json.loads(conn.execute(sql, {"user": username, "key": key}).mappings().first()["data"])
except:
data = {}
return jsonify(data)
Expand All @@ -356,7 +359,8 @@ def delete(self, key):
WHERE key = :key and username = :username
""".format(table=user_bookmark_table))

conn.execute(sql, key=key, username=username)
conn.execute(sql, {"key": key, "username": username})
conn.commit()
conn.close()

return jsonify({"success": True})
Expand Down Expand Up @@ -402,7 +406,8 @@ def put(self, key):
WHERE username = :user and key = :key
""".format(table=user_bookmark_table))

conn.execute(sql, user=username, data=datastr, key=key, date=date, description=description)
conn.execute(sql, {"user": username, "data": datastr, "key": key, "date": date, "description": description})
conn.commit()
conn.close()

return jsonify({"success": True})
Expand Down

0 comments on commit 217c717

Please sign in to comment.