Skip to content

Commit

Permalink
Add example for pass data when upload success
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Dec 8, 2020
1 parent 8613d7d commit 8d77661
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/basic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
import os

from flask import Flask, render_template, request
from flask import Flask, render_template, request, jsonify
from flask_dropzone import Dropzone

basedir = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -28,7 +28,11 @@
def upload():
if request.method == 'POST':
f = request.files.get('file')
f.save(os.path.join(app.config['UPLOADED_PATH'], f.filename))
file_path = os.path.join(app.config['UPLOADED_PATH'], f.filename)
f.save(file_path)
# You can return a JSON response then get it on client side:
# (see template index.html for client implementation)
# return jsonify(uploaded_path=file_path)
return render_template('index.html')


Expand Down
2 changes: 2 additions & 0 deletions examples/basic/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
{{ dropzone.create(action='upload') }}
{{ dropzone.load_js() }}
{{ dropzone.config() }}
{# You can get the success response from server like this: #}
{#{ dropzone.config(custom_options="success: function(file, response){console.log(response);}") }#}
</body>
</html>

0 comments on commit 8d77661

Please sign in to comment.