diff --git a/src/dropper/__init__.py b/src/dropper/__init__.py index 41f3703..b080ef7 100644 --- a/src/dropper/__init__.py +++ b/src/dropper/__init__.py @@ -2,5 +2,6 @@ from flask import Flask, Blueprint app = Flask(__name__) app.secret_key = 'super secret key' +isDebugging = False from . import routes diff --git a/src/dropper/routes.py b/src/dropper/routes.py index d089612..21d05d6 100644 --- a/src/dropper/routes.py +++ b/src/dropper/routes.py @@ -9,7 +9,7 @@ from flask_uploads import UploadSet, configure_uploads, ALL from werkzeug.utils import secure_filename # Application Imports -from . import app +from . import app, isDebugging from .MessageHandler import MessageHandler @@ -154,8 +154,10 @@ def deleteText(): decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8') decodedStr = unquote(decodedStrPart) - print("Encoded String:\n\t" + encodedStr) - print("Decoded String:\n\t" + decodedStr) + if isDebugging: + print("Encoded String:\n\t" + encodedStr) + print("Decoded String:\n\t" + decodedStr) + notesListEncoded.remove(encodedStr) notesListDecoded.remove(decodedStr) updateNotesFile() @@ -192,8 +194,12 @@ def addNote(): decodedStrPart = base64.urlsafe_b64decode(encodedStr.encode('utf-8')).decode('utf-8') decodedStr = unquote(decodedStrPart) - notesListDecoded.append(decodedStr) + if isDebugging: + print("Encoded String:\n\t" + encodedStr) + print("Decoded String:\n\t" + decodedStr) + notesListEncoded.append(encodedStr) + notesListDecoded.append(decodedStr) updateNotesFile() msg = "[Success] Added text entry!" @@ -220,17 +226,8 @@ def updateNotesFile(): file.close() -""""This function returns the SHA-1 hash of the file passed into it""" +""""This function returns the SHA-1 hash of the file path/name passed into it""" def hash_file(filename): - # Make a hash object - h = hashlib.sha1() - # Open file for reading in binary mode - with open(filename,'rb') as file: - # Loop till the end of the file - chunk = 0 - while chunk != b'': - # Read only 1024 bytes at a time - chunk = file.read(1024) - h.update(chunk) - # Return the hex representation of digest - return h.hexdigest() + h = hashlib.sha1() # Make a sha1 hash object + h.update(filename.encode("utf-8")) # Encode string to byte string to update digest + return h.hexdigest() # Return digest string diff --git a/src/dropper/templates/index.html b/src/dropper/templates/index.html index d0fe77b..162f370 100644 --- a/src/dropper/templates/index.html +++ b/src/dropper/templates/index.html @@ -43,23 +43,52 @@ {% for note in notes %}
  • -
    - {% if note.strip().startswith( ("http:", "https:", "ftp:", "file:") ) %} - - {{note}} - - {% elif note.strip() %} - {{note}} - {% endif %} -
    -
    -

    +

    Delete

    + +
    + {% if "youtu.be" in note.strip().lower() or "www.youtube.com/watch?v=" in note.strip().lower() %} + {% if "youtu.be" in note.strip() %} + + {{note}} + + + {% elif "www.youtube.com/watch?v=" in note.strip().lower() %} + + {{note}} + + + {% endif %} + {% elif note.strip().startswith( ("http:", "https:", "ftp:", "file:") ) %} + {% if note.strip().endswith( (".jpg", ".jpeg", ".png", ".gif") ) %} +
    + + {{note}} + + +
    + {% else %} + + {{note}} + + {% endif %} + {% elif note.strip() %} + {{note}} + {% endif %} +
  • {% endfor %}