Вы можете передать значение цвета из маршрута в шаблон:
import flask
app = flask.Flask(__name__)
@app.route('/play/<val>/<color>', methods=['GET'])
def generate_boxes(val, color):
return flask.render_template('boxes.html', color=color, _iter = range(int(val)))
Затем в boxes.html
:
<html>
<style>
.box{
width:100px;
height:100px;
}
</style>
<body>
{%for _ in _iter%}
<div class='box' style='background-color:{{color}}'></div>
<div class='spacer' style='height:10px;'></div>
{%endfor%}
</body>
</html>
Результат: