예제 #1
0
파일: photo.py 프로젝트: yxm0513/flask-ims
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)
예제 #2
0
파일: photo.py 프로젝트: yxm0513/flask-ims
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'))