
from flask import *
from core.util import removeIf, filesInDateOrder
from models import image

def route(app, config):

    assert app is not None

    @app.route('/upload', methods=['POST'])
    def upload():
        """ File upload handler """
    
        f = request.files['pic']
    
        if f:
    
            try:
                i = image.new(f, config)
                return "%s,%s" % (i.location, i.thumb)
            except Exception,e:
                app.logger.debug("Failed to save file %s" % f.filename)
                app.logger.debug(str(e))
                abort(500)
        else:
            abort(501)
