2018-03-10 15:05:49 +02:00
|
|
|
import flask
|
|
|
|
import flask_bootstrap
|
|
|
|
import redis
|
|
|
|
import os
|
|
|
|
import jinja2
|
|
|
|
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
flask_bootstrap.Bootstrap(app)
|
|
|
|
db = redis.StrictRedis(host='localhost', port=6379, db=0)
|
|
|
|
|
|
|
|
|
2018-03-10 16:25:52 +02:00
|
|
|
def build_app(setup_path):
|
2018-03-10 15:05:49 +02:00
|
|
|
|
2018-03-10 16:25:52 +02:00
|
|
|
for version in ("master", "1.8"):
|
2018-03-10 15:05:49 +02:00
|
|
|
|
2018-03-10 16:25:52 +02:00
|
|
|
bp = flask.Blueprint(version, __name__)
|
|
|
|
template_dir = os.path.join(setup_path, version, "templates")
|
|
|
|
flavor_dir = os.path.join(setup_path, version, "flavors")
|
|
|
|
bp.jinja_loader = jinja2.ChoiceLoader([
|
|
|
|
jinja2.FileSystemLoader(template_dir),
|
|
|
|
jinja2.FileSystemLoader(flavor_dir)
|
|
|
|
])
|
2018-03-10 15:05:49 +02:00
|
|
|
|
2018-03-10 16:25:52 +02:00
|
|
|
@bp.route("/")
|
|
|
|
def wizard():
|
|
|
|
return flask.render_template('wizard.html')
|
2018-03-10 15:05:49 +02:00
|
|
|
|
|
|
|
|
2018-03-10 16:25:52 +02:00
|
|
|
@bp.route("/setup", methods=["POST"])
|
|
|
|
def setup():
|
|
|
|
flavor = flask.request.form.get("flavor", "compose")
|
|
|
|
rendered = render_flavor(flavor, "setup.html")
|
|
|
|
return flask.render_template("setup.html", contents=rendered)
|
|
|
|
|
|
|
|
app.register_blueprint(bp, url_prefix="/{}".format(version))
|
|
|
|
|
2018-03-10 15:05:49 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-03-10 16:25:52 +02:00
|
|
|
build_app("/tmp/mailutest")
|
2018-03-10 15:05:49 +02:00
|
|
|
app.run(debug=True)
|