Spaces:
Paused
Paused
Download main.py from DIVY118/HomeAutomationR: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/spaces/DIVY118/HomeAutomationR/resolve/main/main.py
- Command line
-
hf download hf://spaces/DIVY118/HomeAutomationR/main.py
-
curl -L -o main.py https://huggingface.co/spaces/DIVY118/HomeAutomationR/resolve/main/main.py
1.09 kB
| 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 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} | |
| 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) |