def upload(): form = UploadForm(request.form) if not form.validate: flash('form validation failed', 'error') return render_template('photo/upload.html', form = form) if request.method == 'POST' and 'photo' in request.files: filename = photos.save(request.files['photo']) rec = Photo(filename=filename, user=current_user.id) rec.store_to_db() flash("Photo saved.") return redirect(url_for('show', id=rec.id)) return render_template('photo/upload.html', form = form)
def delete(id): photo = Photo.get(id) if photo is None: abort(404) url = photos.url(photo.filename) # try to delete the record and remove it from directory return redirect(url_for('index'))