Use cgi.escape instead of markupsafe.escape