I want to save this image with a custom name so i can make my HTML file display that image easily. How can i do that?
CodePudding user response:
import pathlib
def generate_custom_name(original_file_name):
return "my_custom_file_name" pathlib.Path(original_file_name).suffix
@app.route('/prediction', methods=['POST'])
def success():
if request.method == 'POST':
f = request.files['file']
file_name = generate_custom_name(f.filename)
f.save(os.path.join(UPLOAD_FOLDER, file_name))
return "", 200