HomeAutomationR / main.py
DIVY118's picture
Create main.py
b1d043c verified
raw
history blame contribute delete
No virus
736 Bytes
from fastapi import FastAPI
from rich import print
app = FastAPI()
Home = {
"bulb": {
"discription": "bed room light only",
"value": 0,
"can be": [0, 1],
"pin": "D1"
},
"fan": {
"discription": "hall fan",
"value": 0,
"can be": [0, 1, 2, 3, 4, 5],
"pin": "D3"
}
}
@app.get("/")
def read_root():
return {"message": "Welcome to this fantastic app!"}
@app.get("/home")
def read_home():
global Home
print(Home)
return Home
@app.post("/home")
def write_home(data: dict):
global Home
Home = data
print(Home)
return Home
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=7680)