better code structure  and use jinja2 to set html title