import os def read_module_content(file_path): with open(file_path, 'r', encoding='utf-8') as file: return file.read() def main(): modules_dir = 'modules' pages_dir = 'pages' output_dir = 'output' os.makedirs(output_dir, exist_ok=True) # Read the header and footer content header_content = read_module_content(os.path.join(modules_dir, 'header.html')) footer_content = read_module_content(os.path.join(modules_dir, 'footer.html')) # Process each page in the pages directory for page in os.listdir(pages_dir): if page.endswith('.html'): with open(os.path.join(pages_dir, page), 'r', encoding='utf-8') as file: page_content = file.read() # Construct the full page content full_content = (f'\n\n\n' f' \n' f' \n' f' \n' f' {page.title()}\n' f'\n\n' f'{header_content}\n' f'{page_content}\n' f'{footer_content}\n' f'\n') # Write the full content to the output directory with open(os.path.join(output_dir, page), 'w', encoding='utf-8') as output_file: output_file.write(full_content) if __name__ == "__main__": main()