Python Forum

Full Version: Download images generated by user input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm building an web app that allows users to download images based on they input. The main url is constant, the filename is known by user and is used as input. The amount of pictures could vary from 1 to 7. I'm able to generate the urls for the pictures, but I can't figure out how to zip and download them.

I tried with jszip(see in index.html file) but I can't figure out how to connect it so it generates the zip file and download all existing images from 1 to 7. looks like this :

from flask import Flask, jsonify, render_template, request

app = Flask(__name__)

def index():
    return render_template('index.html')

@app.route('/generate', methods=['GET'])
def generate():
    prefix = request.args.get('prefix')
    urls = []
    for number in range(1, 8):
        urls.append('{p}-{n}.jpg'.format(p=prefix, n=number))
    return jsonify(result=urls)
index.html looks like this :

Expecting to generate the zip file when clicked the download button and download it.

Not happening anything just the urls are generated. Think I'm missing something small but can't figure out what exactly :(

On input try this : AMSPP-BL