tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

util.py (509B)


      1 import os
      2 
      3 
      4 def allowed_extension(filename):
      5     return get_file_extension(filename) in "jpg"
      6 
      7 
      8 def get_file_extension(filename):
      9     extension = filename.split(".")
     10 
     11     if len(extension) > 2:
     12         raise ValueError("Invalid file extension")
     13 
     14     return extension[1].lower()
     15 
     16 
     17 def get_user_picture(username):
     18     if os.path.isfile("uploads/pictures/custom/" + username + ".jpg"):
     19         return "uploads/pictures/custom/" + username + ".jpg"
     20     else:
     21         return "uploads/pictures/default/default.jpg"