예제 #1
0
def upload_image():
    img_file = request.files['image']
    if img_file:
        ext = misc.extension(img_file.filename)
        app.config['IMG_COUNT'] = misc.get_img_count() + 1

        filename = secure_filename('.'.join([str(app.config['IMG_COUNT']), ext]))
        img_file.save(os.path.realpath(os.path.join(app.config['UPLOAD_FOLDER'], filename)))

        return jsonify({'status': 'successful'})
예제 #2
0
# encoding: utf-8
import os

from flask import Flask, url_for
from web.lib import misc
from web.lib.flask_bootstrap import Bootstrap
from web.lib.img_lib import ImageLibrary

app = Flask(__name__)

app.debug = True
app.config['UPLOAD_FOLDER'] = os.path.join(misc.prefix, 'images')
app.config['IMG_COUNT'] = misc.get_img_count()

Bootstrap(app)

if 'img_lib' not in locals():
    img_lib = ImageLibrary()