'How to upload file from python Flask web app to Supabase Storage

I want to be able to upload a file from Flask to Supabase Storage, but it only has documentation for the javascript api link to docs.

Also, I can't find any examples or any open source project that does that. Here it is my function to upload:

def upload_file(self):
    if 'file' not in request.files:
        flash('No file part')
        return redirect('/')
    file = request.files['file']
    if file.filename == '':
        flash('No selected file')
        return redirect('/')
    filename = secure_filename(file.filename)
    # upload to supabase storage
    return file.path


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source