from flask import Blueprint, render_template, request, redirect, url_for, flash from mg import application as m, tasks from mg import pool from mgweb.decorators import webtask from mgweb import queue blueprint = Blueprint('install_store', __name__) @blueprint.route('/') def index(): return render_template('install_store.html', dists=m.pool.list_local(pool.dists)) @blueprint.route('/install', methods=["POST"]) @webtask def install(): tasks.install_store(request.form['store_name'], request.form['magento_version']) #queue.schedule(queue.Task(fn=tasks.install_store, args=[request.form['store_name'], request.form['magento_version']], desc="Install %s to %s" % (request.form['magento_version'], request.form['store_name']))) flash('Store installed', category='success') return redirect(url_for('stores.index'))