Spaces:
Sleeping
Sleeping
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" | |
} | |
} | |
def read_root(): | |
return {"message": "Welcome to this fantastic app!"} | |
def read_home(): | |
global Home | |
print(Home) | |
return 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) |