1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00
Mailu/config/server.py

42 lines
1.1 KiB
Python
Raw Normal View History

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 16:25:52 +02:00
for version in ("master", "1.8"):
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 16:25:52 +02:00
@bp.route("/")
def wizard():
return flask.render_template('wizard.html')
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))
if __name__ == "__main__":
2018-03-10 16:25:52 +02:00
build_app("/tmp/mailutest")
app.run(debug=True)