Hey guys, I've solve my last problem with help from @perfringo ! (https://python-forum.io/Thread-Download-...7#pid57947)
Now I've got into another problem. How do I download multiple images with just one click ? In html. I'm creating a web app based on flask.
So my run.py file is looking like this :
and my index.html is looking like this :
So the user will input a code, and the form will generate 6 urls. Now I have no idea how to download them all using Javascript and jquery or something else. Any help is appreciated.
Now I've got into another problem. How do I download multiple images with just one click ? In html. I'm creating a web app based on flask.
So my run.py file is looking like this :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from flask import Flask, jsonify, render_template, request app = Flask(__name__) @app .route( '/' ) 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 , 7 ): return jsonify(result = urls) |
<!doctype html>
<html lang="en">
<html>
<head>
<title>Image Grabber v1.0</title>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</head>
<body>
<center>
<script type=text/javascript>
$SCRIPT_ROOT = {{ request.script_root|tojson|safe }};
$( document ).ready(function() {
$('#download').bind('click', function() {
$.getJSON($SCRIPT_ROOT + '/generate', {
prefix: $('input[name="prefix"]').val()
}, function(data) {
$("#result").text(data.result);
});
return false;
});
});
</script><br>
<h2>Image Grabber v1.0</h2>
<p><input type=text size=45 name=prefix>
<span id=result></span>
<p><button type="submit" id=download>Download</button></p>
</center>
</body>
</html>
So the user will input a code, and the form will generate 6 urls. Now I have no idea how to download them all using Javascript and jquery or something else. Any help is appreciated.