Color selector without session



examples/flask/color/color.py
from flask import Flask, request, render_template
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/color/templates/main.html
<style>
* {
  background-color: #{{ color }};
}
</style>

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