Pylinting and refactoring of _serve_directory_html