(self, directory)
| 308 | handler.wfile.write(json.dumps({"status": "error", "message": str(e)}).encode('utf-8')) |
| 309 | |
| 310 | def generate_html_for_csv_files(self, directory): |
| 311 | html = '<div class="credentials-container">\n' |
| 312 | for filename in os.listdir(directory): |
| 313 | if filename.endswith('.csv'): |
| 314 | filepath = os.path.join(directory, filename) |
| 315 | html += f'<h2>{filename}</h2>\n' |
| 316 | html += '<table class="styled-table">\n<thead>\n<tr>\n' |
| 317 | with open(filepath, 'r') as file: |
| 318 | reader = csv.reader(file) |
| 319 | headers = next(reader) |
| 320 | for header in headers: |
| 321 | html += f'<th>{header}</th>\n' |
| 322 | html += '</tr>\n</thead>\n<tbody>\n' |
| 323 | for row in reader: |
| 324 | html += '<tr>\n' |
| 325 | for cell in row: |
| 326 | html += f'<td>{cell}</td>\n' |
| 327 | html += '</tr>\n' |
| 328 | html += '</tbody>\n</table>\n' |
| 329 | html += '</div>\n' |
| 330 | return html |
| 331 | |
| 332 | def serve_file(self, handler, filename): |
| 333 | try: |
no outgoing calls
no test coverage detected