examples/flask/11/color.py
from flask import Flask, request, render_template, session
import re
app = Flask(__name__)


@app.route("/",methods=['GET', 'POST'] )
def main():
    color = "FFFFFF"
    new_color = request.form.get('color', '')
    if re.search(r'^[0-9A-F]{6}$', new_color):
        color = new_color

    return render_template('main.html', color = color)

examples/flask/11/templates/main.html
<style>
* {
  background-color: #{{ color }};
}
</style>

<form method="POST">
<input name="color" value="{{ color }}">
<input type="submit" value="Save">
</form>
<p>
<a href="/">home</a>