Minimal example for api endpoint
Some checks failed
Build RPi Pico firmware image / Build-Firmware (push) Successful in 3m22s
Check code formatting / Check-C-Format (push) Successful in 8s
Check code formatting / Check-Python-Flake8 (push) Failing after 9s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s

This commit is contained in:
2025-03-18 22:03:05 +01:00
parent 86a2001ed4
commit 0e3ee0e44e

View File

@@ -35,4 +35,16 @@ async def index(request):
print(f" cookies: {request.cookies}")
return "TonberryPico says 'Hello World!'"
@app.route('/v1/api/playback/control', methods=['POST'])
async def playback_control(request):
if not request.json:
return {'success': False}
# Example:
# curl -H "Content-Type: application/json" --data '{"action": "play", "target_type": "audio_file", "target_id": "1234"}' http://192.168.4.1/v1/api/playback/control
print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \
{request.json["target_id"]}')
app.run(port=80)