I have made a flask server REST API that does an upload to a specific folder. The upload must comply to a specific file extension, and must be in a specific folder.
So i made these two app.configs:
app.config['UPLOAD_EXTENSIONS'] = ['.stp', '.step'] app.config['UPLOAD_PATH'] = 'uploads'
However, i want to make a new route, for a new upload of a specific file extension to another folder.
So can i have two sets of
One set will be for
folder1 and the other set for
Try using the extension Flask-Uploads .
Or, proceeding from the file format, form a subdirectory in your UPLOAD_PATH.
import os def select_directory(filename: str) -> str: file_format = filename.split('.') your_path1 = 'path1' your_path2 = 'path2' if file_format in ('your format1', 'your format2'): full_path = os.path.join(app.config['UPLOAD_FOLDER'], your_path1, filename) else: full_path = os.path.join(app.config['UPLOAD_FOLDER'], your_path2, filename) return full_path