Keep your CLOUDINARY_URL, session secrets, and other API Keys secret. Add .env to your .gitignore. You don't want to push your env file to GitHub or anyone can take your API keys and use your accounts.
Dependencies
To use Cloudinary in your Flask app, you need to install two packages:
To let your user upload images to your Flask app, you need an <input type="file" /> and the proper encoding type for the form: enctype=multipart/form-data
Cloudinary image urls look like this: https://res.cloudinary.com/dlgwpetvg/image/upload/v1678065074/g9cpesuzdqyn4hkawjcv.jpg. Store this url in your database tables.
cur.execute(
'INSERT INTO something (image_url) VALUES (%s)',
[image_url]
)
Fancier Cloudinary Usage
If you want to use Cloudinary's transformations on your images, store the image's public_id: