MCPcopy
hub / github.com/cft0808/edict / do_GET

Method do_GET

dashboard/server.py:2403–2526  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2401 return False
2402
2403 def do_GET(self):
2404 p = urlparse(self.path).path.rstrip('/')
2405 # 认证状态端点(公开)
2406 if p == '/api/auth/status':
2407 self.send_json({'enabled': auth_enabled(), 'configured': auth_configured()})
2408 return
2409 if self._check_auth():
2410 return
2411 if p in ('', '/dashboard', '/dashboard.html'):
2412 self.send_file(DIST / 'index.html')
2413 elif p == '/healthz':
2414 task_data_dir = get_task_data_dir()
2415 checks = {'dataDir': task_data_dir.is_dir(), 'tasksReadable': (task_data_dir / 'tasks_source.json').exists()}
2416 checks['dataWritable'] = os.access(str(task_data_dir), os.W_OK)
2417 all_ok = all(checks.values())
2418 self.send_json({'status': 'ok' if all_ok else 'degraded', 'ts': now_iso(), 'checks': checks})
2419 elif p == '/api/live-status':
2420 task_data_dir = get_task_data_dir()
2421 self.send_json(read_json(task_data_dir / 'live_status.json'))
2422 elif p == '/api/agent-config':
2423 self.send_json(read_json(DATA / 'agent_config.json'))
2424 elif p == '/api/model-change-log':
2425 self.send_json(read_json(DATA / 'model_change_log.json', []))
2426 elif p == '/api/last-result':
2427 self.send_json(read_json(DATA / 'last_model_change_result.json', {}))
2428 elif p == '/api/officials-stats':
2429 self.send_json(read_json(DATA / 'officials_stats.json', {}))
2430 elif p == '/api/morning-brief':
2431 self.send_json(read_json(DATA / 'morning_brief.json', {}))
2432 elif p == '/api/morning-config':
2433 migrate_notification_config()
2434 self.send_json(read_json(DATA / 'morning_brief_config.json', {
2435 'categories': [
2436 {'name': '政治', 'enabled': True},
2437 {'name': '军事', 'enabled': True},
2438 {'name': '经济', 'enabled': True},
2439 {'name': 'AI大模型', 'enabled': True},
2440 ],
2441 'keywords': [], 'custom_feeds': [],
2442 'notification': {'enabled': True, 'channel': 'feishu', 'webhook': ''},
2443 }))
2444 elif p == '/api/notification-channels':
2445 self.send_json({'ok': True, 'channels': get_channel_info()})
2446 elif p.startswith('/api/morning-brief/'):
2447 date = p.split('/')[-1]
2448 # 标准化日期格式为 YYYYMMDD(兼容 YYYY-MM-DD 输入)
2449 date_clean = date.replace('-', '')
2450 if not date_clean.isdigit() or len(date_clean) != 8:
2451 self.send_json({'ok': False, 'error': f'日期格式无效: {date},请使用 YYYYMMDD'}, 400)
2452 return
2453 self.send_json(read_json(DATA / f'morning_brief_{date_clean}.json', {}))
2454 elif p == '/api/remote-skills-list':
2455 self.send_json(get_remote_skills_list())
2456 elif p.startswith('/api/skill-content/'):
2457 # /api/skill-content/{agentId}/{skillName}
2458 parts = p.replace('/api/skill-content/', '').split('/', 1)
2459 if len(parts) == 2:
2460 self.send_json(read_skill_content(parts[0], parts[1]))

Callers

nothing calls this directly

Calls 15

send_jsonMethod · 0.95
_check_authMethod · 0.95
send_fileMethod · 0.95
_serve_staticMethod · 0.95
now_isoFunction · 0.90
read_jsonFunction · 0.90
get_channel_infoFunction · 0.90
get_task_data_dirFunction · 0.85
get_remote_skills_listFunction · 0.85
read_skill_contentFunction · 0.85
get_task_activityFunction · 0.85

Tested by

no test coverage detected