File size: 1,092 Bytes
b1d043c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fac3b90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1d043c
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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.get("/r")
def f():
    global Home
    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"
        }
    }
    return {"r":True}


@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)