docs: def mime_type(filename):
  	""" Guess mime type for the given file name
  
  	Note: this implementation uses python_magic package which is not thread-safe, as a workaround global lock is
  	used for the ability to work in threaded environment
  
  	:param filename: file name to guess
  	:return: str
  	"""
  	# TODO: write lock-free mime_type function
  	try:
  		__mime_lock.acquire()
  
  		extension = filename.split(".")
  		extension = extension[len(extension) - 1]
  
  		if extension == "woff2":
  			return "application/font-woff2"
  		if extension == "css":
  			return "text/css"
  
  		m = magic.from_file(filename, mime=True)
  		m = m.decode() if isinstance(m, bytes) else m  # compatibility fix, some versions return bytes some - str
  		if m == "text/plain":
  			guessed_type = mimetypes.guess_type(filename)[0]  # for js-detection
  			if guessed_type:
  				return guessed_type
  		return m
  	finally:
  		__mime_lock.release()