MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / remove_ai_token

Function remove_ai_token

webapp_modern.py:19320–19349  ·  view source on GitHub ↗

Remove OpenAI API token from .env file

()

Source from the content-addressed store, hash-verified

19318 return jsonify({'error': 'Invalid path'}), 400
19319 actual_path = resolved
19320 elif file_path == '/logs' or file_path.startswith('/logs/'):
19321 try:
19322 actual_path = _resolve_legacy_path('/logs', os.path.join(shared_data.datadir, 'logs'), file_path)
19323 except ValueError:
19324 return jsonify({'error': 'Invalid path'}), 400
19325 elif file_path == '/backups' or file_path.startswith('/backups/'):
19326 try:
19327 actual_path = _resolve_legacy_path('/backups', shared_data.backupdir, file_path)
19328 except ValueError:
19329 return jsonify({'error': 'Invalid path'}), 400
19330 elif file_path == '/uploads' or file_path.startswith('/uploads/'):
19331 try:
19332 actual_path = _resolve_legacy_path('/uploads', shared_data.upload_dir, file_path)
19333 except ValueError:
19334 return jsonify({'error': 'Invalid path'}), 400
19335 else:
19336 return jsonify({'error': 'Invalid path'}), 400
19337
19338 if not os.path.isfile(actual_path):
19339 return jsonify({'error': 'File not found'}), 404
19340
19341 actual_path = os.path.realpath(actual_path)
19342
19343 mime_type, _ = mimetypes.guess_type(actual_path)
19344 mime_type = mime_type or 'application/octet-stream'
19345 file_size = os.path.getsize(actual_path)
19346 ext = os.path.splitext(actual_path)[1].lower()
19347
19348 TEXT_EXTENSIONS = {'.txt', '.log', '.csv', '.json', '.xml', '.yaml', '.yml',
19349 '.md', '.conf', '.cfg', '.ini', '.nmap', '.gnmap', '.sh', '.py'}
19350 IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp', '.svg'}
19351
19352 if ext in IMAGE_EXTENSIONS:

Callers

nothing calls this directly

Calls 2

EnvManagerClass · 0.90
errorMethod · 0.80

Tested by

no test coverage detected