diff --git a/deletelink.py b/deletelink.py index 0f67f9d10c05e654f8631a1cf05f8339417c10fc..f7213de798d96bdc4d9abbe8245db1c3f420f544 100644 --- a/deletelink.py +++ b/deletelink.py @@ -7,17 +7,17 @@ def deleteLink(request, s): loginbar = "Hello " + s.loads(request.cookies.get('username')) + ' (<a href="/user/logout" style="color:white">logout</a>)' # generate the login form loginbar = loginbar + "" #to hide the unused variable message except: - return redirect("/user/login") # if user is not logged in redirect him to the login page + abort(404) #if the user is not logged in, hide this page and return not found linkToDelete = request.args.get('link') #get the link, which the user want's to delete from the parameter in the url. with connect('db/urls.db') as conn: cursor = conn.cursor() try: - cursor.execute('DELETE FROM WEB_URL WHERE SHORT_URL=? AND USERNAME=?', [linkToDelete, userID]) #Delete the entrie - cursor.execute('DELETE FROM ANALYTICS WHERE SHORT_URL=?', [linkToDelete]) #Delete the entrie + cursor.execute('DELETE FROM WEB_URL WHERE SHORT_URL=? AND USERNAME=?', [linkToDelete, userID]) #Delete the mapping + cursor.execute('DELETE FROM ANALYTICS WHERE SHORT_URL=?', [linkToDelete]) #Delete the statistics return "OK" #response is only for ajax request except: - abort(500) + abort(500) #return internal server error, if something fails if (__name__ == "__main__"): print("This file is not made fore direct call, please run the main.py")