File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import os
2+ import htmlmin
3+
4+ def minify_html_file (file_path ):
5+ # Read the original HTML file
6+ with open (file_path , 'r' , encoding = 'utf-8' ) as file :
7+ html_content = file .read ()
8+
9+ # Minify the HTML content
10+ minified_content = htmlmin .minify (html_content , remove_comments = True , remove_empty_space = True )
11+
12+ # Write the minified content back to the file
13+ with open (file_path , 'w' , encoding = 'utf-8' ) as file :
14+ file .write (minified_content )
15+ print (f"Minified: { file_path } " )
16+
17+ def find_and_minify_html_files (root_directory ):
18+ # Walk through all directories and files
19+ for root , _ , files in os .walk (root_directory ):
20+ for file in files :
21+ if file .endswith ('.html' ):
22+ file_path = os .path .join (root , file )
23+ minify_html_file (file_path )
24+
25+ if __name__ == "__main__" :
26+ # Get the current directory
27+ current_directory = os .getcwd ()
28+ # Find and minify all HTML files
29+ find_and_minify_html_files (current_directory )
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def get_established_connections():
4545 # ipv4_dict = [ip for ip in ipv4_dict if ip.startswith('192.168')]
4646 # return ipv4_dict[0] if ipv4_dict else "N/A", ipv6_dict
4747 ipv4 = [ip for ip in ipv4_set if ip .startswith ('192.168' )][0 ]
48- ipv6 = list (ipv6_set )[0 ]
48+ ipv6 = list (ipv6_set )[0 ] if ipv6_set else "N/A"
4949
5050 return ipv4 , ipv6
5151
You can’t perform that action at this time.
0 commit comments