Feb-20-2019, 10:46 AM
I have written an app https://images99acres.herokuapp.com/.
This app allow users to upload images, if i run this app locally this app uploads images and saves it to the path which i have designated,
but i uploaded this app on heroku and when someone uploads images it uploads images here https://images99acres.herokuapp.com/_upl...onment.jpg
"_uploads/photos/image.jpg"
Below is my code:
my previous post was for deployment which got solved
This app allow users to upload images, if i run this app locally this app uploads images and saves it to the path which i have designated,
but i uploaded this app on heroku and when someone uploads images it uploads images here https://images99acres.herokuapp.com/_upl...onment.jpg
"_uploads/photos/image.jpg"
Below is my code:
from flask import Flask, redirect, render_template, request, session, url_for from flask_dropzone import Dropzone from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class import os app = Flask(__name__) dropzone = Dropzone(app) app.config['SECRET_KEY'] = 'supersecretkeygoeshere' # Dropzone settings app.config['DROPZONE_UPLOAD_MULTIPLE'] = True app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True app.config['DROPZONE_ALLOWED_FILE_TYPE'] = 'image/*' app.config['DROPZONE_REDIRECT_VIEW'] = 'results' # Uploads settings app.config['UPLOADED_PHOTOS_DEST'] = os.getcwd() + '/uploads' photos = UploadSet('photos', IMAGES) configure_uploads(app, photos) patch_request_class(app) # set maximum file size, default is 16MB @app.route('/', methods=['GET', 'POST']) def index(): # set session for image results if "file_urls" not in session: session['file_urls'] = [] # list to hold our uploaded image urls file_urls = session['file_urls'] # handle image upload from Dropszone if request.method == 'POST': file_obj = request.files for f in file_obj: file = request.files.get(f) # save the file with to our photos folder filename = photos.save( file, name=file.filename ) # append image urls file_urls.append(photos.url(filename)) session['file_urls'] = file_urls return "uploading..." # return dropzone template on GET request return render_template('index.html') @app.route('/results') def results(): # redirect to home if no images to display if "file_urls" not in session or session['file_urls'] == []: return redirect(url_for('index')) # set the file_urls and remove the session variable file_urls = session['file_urls'] session.pop('file_urls', None) return render_template('results.html', file_urls=file_urls) if __name__=="__main__": app.run() #app.run(debug=True)hat should i do? how can i solve this?
my previous post was for deployment which got solved