Generate a self-signed SSL certificate
(cert_path: str, key_path: str)
| 19656 | |
| 19657 | except Exception as e: |
| 19658 | logger.error(f"Error in legacy file listing: {e}") |
| 19659 | return jsonify([]) |
| 19660 | |
| 19661 | @app.route('/download_file') |
| 19662 | def legacy_download_file(): |
| 19663 | """Legacy endpoint for file download""" |
| 19664 | try: |
| 19665 | file_path = request.args.get('path') |
| 19666 | if not file_path: |
| 19667 | return "File path required", 400 |
| 19668 | |
| 19669 | # Check if file exists in data_stolen directory |
| 19670 | actual_path = os.path.join(shared_data.datastolendir, file_path) |
| 19671 | if os.path.isfile(actual_path): |
| 19672 | return send_from_directory( |
| 19673 | os.path.dirname(actual_path), |
| 19674 | os.path.basename(actual_path), |
| 19675 | as_attachment=True |
| 19676 | ) |
| 19677 | else: |
| 19678 | return "File not found", 404 |
| 19679 | except Exception as e: |
| 19680 | logger.error(f"Error in legacy file download: {e}") |
| 19681 | return str(e), 500 |
| 19682 | |
| 19683 | # ============================================================================ |
| 19684 | # (Image gallery endpoints removed) |
| 19685 | # ============================================================================ |
| 19686 | |
| 19687 | def format_bytes(bytes_value): |
| 19688 | """Format bytes to human readable format""" |
| 19689 | if bytes_value == 0: |
| 19690 | return '0 B' |
| 19691 | |
| 19692 | for unit in ['B', 'KB', 'MB', 'GB']: |
| 19693 | if bytes_value < 1024.0: |
| 19694 | return f"{bytes_value:.1f} {unit}" |
| 19695 | bytes_value /= 1024.0 |
| 19696 | return f"{bytes_value:.1f} TB" |
| 19697 | |
| 19698 | # ============================================================================ |
| 19699 | # SYSTEM MONITORING ENDPOINTS |
| 19700 | # ============================================================================ |
| 19701 | |
| 19702 | @app.route('/api/system/status') |
| 19703 | def get_system_status_api(): |
| 19704 | """Get comprehensive system status""" |
| 19705 | try: |
| 19706 | if not psutil_available: |
| 19707 | return jsonify({'error': 'System monitoring not available'}), 503 |
| 19708 | |
| 19709 | # CPU Information |
| 19710 | cpu_percent = psutil.cpu_percent(interval=1) |
| 19711 | cpu_count = psutil.cpu_count() |
| 19712 | cpu_freq = psutil.cpu_freq() |
| 19713 | |
| 19714 | # Memory Information |
| 19715 | memory = psutil.virtual_memory() |
no test coverage detected