I've been trying to use jqxUploadFiles but instead of php I need to use python.
In a code like below;
from flask import request
from flask.ext.uploads import UploadSet, configure_uploads, ALL
def upload_file():
files = UploadSet('files', ALL)
app.config['UPLOADED_FILES_DEST'] = '/uploads'
configure_uploads(app, files)
filename = files.save(request.files['files'])
return filename
where app = Flask(__name__)
but in this project there is;
main = Blueprint('main', __name__)
where it used like @main.route('/', methods=['GET', 'POST'])
and there is a create_app function;
def create_app():
app = Flask(__name__)
app.config.from_object(config['development'])
with app.app_context():
db.app = app
db.init_app(app)
db.create_all()
and it is used in manage.py file;
app = create_app()
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db)
manager.add_command("shell", Shell(make_context=make_shell_context))
@manager.command
def test():
"""Run the unit tests."""
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)
if __name__ == '__main__':
manager.run()
So I need to use a function like "upload_file()" but I couldn't understand how "app" created by "create_app()" and Blueprint() relates to each other and how can I use it in upload_file().