blog/app/routes.py
def upload_file():
    """ Accepts a post containing a file, parks it in uploads. """

    # redirect to admin it NOT a post
    if flask.request.method == 'GET':
        return flask.redirect(flask.url_for('admin'))

    logger = util.get_logger(log_name='upload')

    def allowed_file(filename):
        """ private method to check file names for ext. """
        return '.' in filename and filename.rsplit('.', 1)[1].lower() \
            in app.config['ALLOWED_EXTENSIONS']

    processed = 0
    for in_file in flask.request.files.getlist('file[]'):
        if allowed_file(in_file.filename):
            image_obj = models.images.Image(raw_upload=in_file)
            processed += 1

    msg = "Uploaded %s files successfully!" % processed
    return flask.redirect(flask.url_for('admin'))
 Accepts a post containing a file, parks it in uploads. 
Accepts a post containing a file, parks it in uploads.
Accepts a post containing a file parks it in uploads .
def upload_file():
    if flask.request.method == 'GET':
        return flask.redirect(flask.url_for('admin'))
    logger = util.get_logger(log_name='upload')
    def allowed_file(filename):
        return '.' in filename and filename.rsplit('.', 1)[1].lower() \
            in app.config['ALLOWED_EXTENSIONS']
    processed = 0
    for in_file in flask.request.files.getlist('file[]'):
        if allowed_file(in_file.filename):
            image_obj = models.images.Image(raw_upload=in_file)
            processed += 1
    msg = "Uploaded %s files successfully!" % processed
    return flask.redirect(flask.url_for('admin'))
def upload_file ( ) : if flask . request . method == 'GET' : return flask . redirect ( flask . url_for ( 'admin' ) ) logger = util . get_logger ( log_name = 'upload' ) def allowed_file ( filename ) : """ private method to check file names for ext. """ return '.' in filename and filename . rsplit ( '.' , 1 ) [ 1 ] . lower ( ) in app . config [ 'ALLOWED_EXTENSIONS' ] processed = 0 for in_file in flask . request . files . getlist ( 'file[]' ) : if allowed_file ( in_file . filename ) : image_obj = models . images . Image ( raw_upload = in_file ) processed += 1 msg = "Uploaded %s files successfully!" % processed return flask . redirect ( flask . url_for ( 'admin' ) )
Accepts a post containing a file, parks it in uploads.
Accepts a post containing a file parks it in uploads .
""" Accepts a post containing a file, parks it in uploads. """ # redirect to admin it NOT a post """ private method to check file names for ext. """