cgi.escape is deprecated. Use html.escape instead. https://docs.python.org/3/library/cgi.html#cgi.escape