File size: 361 Bytes
c71f981
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import os

def file_type(file_path, allowed_extensions=['pdf', 'pptx', 'docx']):

    _, extension = os.path.splitext(file_path)
    extension = extension.lower()[1:]  # Remove the dot and convert to lowercase
    
    if extension in allowed_extensions:
        return extension
    
    # If neither MIME type nor extension match, return None
    return None