flask_uploads.exceptions.UploadNotAllowed 1


filename1 = photos.save(request.files['image_1'], name=secrets.token_hex(10)+ ".")

Here is what the above code is Doing:
1. We’re importing the secrets module.
2. We’re generating a random hexadecimal string using the secrets.token_hex() function.
3. We’re saving the image to our photos set using the save() method.
4. We’re passing the request.files[‘image_1’] object as the first argument to the save() method.
5. We’re passing the generated random string as the name argument to the save() method.
6. We’re appending the .jpg extension to the end of the generated random string.
7. We’re saving the filename of the image to a variable called filename1.

Similar Posts