flask upload

import os
from flask import Flask, flash, request, redirect, url_for
from werkzeug.utils import secure_filename

UPLOAD_FOLDER = '/path/to/the/uploads'
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'}

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

Here is what the above code is Doing:
1. We’re creating a new Flask object.
2. We’re setting the UPLOAD_FOLDER variable to the path where we want to store our uploaded files.
3. We’re creating a list of extensions that are allowed to be uploaded.