1
Fork 0
mirror of https://github.com/RGBCube/GDUS synced 2025-07-28 05:27:45 +00:00

Return OK

This commit is contained in:
RGBCube 2023-12-20 12:33:21 +03:00
parent 60c3201ddf
commit be1bb01bdf
No known key found for this signature in database
5 changed files with 44 additions and 21 deletions

29
rpid/main.py Normal file
View file

@ -0,0 +1,29 @@
import os
from fastapi import FastAPI
from RPi import GPIO as gpio
LED_PIN = 17
led_state = False
gipo.setmode(gpio.BCM)
gpio.output(LED_PIN, int(led_state))
app = FastAPI()
@app.get("/led/toggle")
async def toggle() -> str:
led_state = not led_state
gpio.output(LED_PIN, int(led_state))
return f"TOGGLE OK, NEW STATE: {'ON' if not led_state else 'OFF'}"
@app.get("/speak")
async def speak(text: str) -> str:
ret = os.system(f'text2speech "{text}""')
return f"TEXT {'OK' if ret == 0 else 'FAIL'}, TEXT: {text}";
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="localhost", port=3000)