Python - ¿Como puedo introducir logica a un formulario HTML con Python?

Filtrado por el usuario: Pedro
Filtrado por el usuario 'Pedro' (Eliminar fitro)
 
Vista: