33 lines
886 B
Python
33 lines
886 B
Python
import flask
|
|
import solo_turnier
|
|
import logging
|
|
|
|
_l = logging.getLogger(__name__)
|
|
|
|
|
|
def startFlask(
|
|
batchWorker: solo_turnier.batch.BatchWorker,
|
|
debug: bool = False,
|
|
port: int = 8082,
|
|
showOnlyFinalists: bool = True,
|
|
externalDebugger: bool = False,
|
|
):
|
|
app = flask.Flask(__name__)
|
|
|
|
@app.route("/")
|
|
def index():
|
|
combinedData = batchWorker.run(False)
|
|
_l.debug("Show only finalists %s", showOnlyFinalists)
|
|
|
|
return flask.render_template(
|
|
"index.html", data=combinedData, onlyFinalists=showOnlyFinalists
|
|
)
|
|
|
|
@app.get("/custom.css")
|
|
def css():
|
|
ret = flask.render_template("custom.css", onlyFinalists=showOnlyFinalists)
|
|
return flask.Response(ret, mimetype="text/css")
|
|
|
|
useReloader = debug and not externalDebugger
|
|
app.run(host="0.0.0.0", port=port, debug=debug, use_reloader=useReloader)
|