Get AI-generated network security summary
()
| 19082 | virtual_path = f"{vroot}/{slug}/{inner}" |
| 19083 | |
| 19084 | files.append({ |
| 19085 | 'filename': fname, |
| 19086 | 'category': category, |
| 19087 | 'size': _format_bytes_simple(stat.st_size), |
| 19088 | 'modified': _format_timestamp_simple(stat.st_mtime), |
| 19089 | 'virtual_path': virtual_path, |
| 19090 | }) |
| 19091 | except OSError: |
| 19092 | pass |
| 19093 | |
| 19094 | return jsonify({ |
| 19095 | 'success': True, |
| 19096 | 'slug': slug, |
| 19097 | 'ssid': ssid, |
| 19098 | 'files': files, |
| 19099 | 'total': len(files), |
| 19100 | }) |
| 19101 | except Exception as exc: |
| 19102 | logger.error(f"Error listing files for network '{slug}': {exc}") |
| 19103 | return jsonify({'success': False, 'error': str(exc)}), 500 |
| 19104 | |
| 19105 | |
| 19106 | def _format_bytes_simple(size): |
| 19107 | for unit in ('B', 'KB', 'MB', 'GB'): |
| 19108 | if size < 1024: |
| 19109 | return f"{size:.1f} {unit}" if unit != 'B' else f"{size} B" |
| 19110 | size /= 1024 |
| 19111 | return f"{size:.1f} TB" |
| 19112 | |
| 19113 | |
| 19114 | def _format_timestamp_simple(ts): |
| 19115 | import datetime as _dt |
| 19116 | try: |
| 19117 | return _dt.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M') |
nothing calls this directly
no test coverage detected