feat: add runtime listen-only switch and API controls
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from flask import Flask, jsonify, request
|
||||
|
||||
from .logger import setup_logger
|
||||
from .runtime_switch import is_listen_only, set_listen_only
|
||||
from .task_manager import TaskManager
|
||||
|
||||
|
||||
@@ -15,6 +16,20 @@ def create_http_app(task_manager: TaskManager | None = None) -> Flask:
|
||||
def health():
|
||||
return jsonify({'ok': True})
|
||||
|
||||
@app.get('/api/runtime/listen_only')
|
||||
def get_listen_only():
|
||||
return jsonify({'ok': True, 'listen_only': is_listen_only()})
|
||||
|
||||
@app.post('/api/runtime/listen_only')
|
||||
def set_listen_only_mode():
|
||||
body = request.get_json(silent=True) or {}
|
||||
if "enabled" not in body:
|
||||
return jsonify({'ok': False, 'error': 'enabled required'}), 400
|
||||
enabled = bool(body.get("enabled"))
|
||||
current = set_listen_only(enabled)
|
||||
logger.info('[运行时] listen_only=%s', current)
|
||||
return jsonify({'ok': True, 'listen_only': current})
|
||||
|
||||
@app.post('/api/task/receive')
|
||||
def receive_task():
|
||||
payload = request.get_json(silent=True) or {}
|
||||
|
||||
Reference in New Issue
Block a user