Skip to content

Commit 2475bec

Browse files
committed
Fix routings and docs
1 parent 230eed6 commit 2475bec

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Simple, light-weight server for RF commands (such as: IR, 433 MHz etc.) for appl
77
* In project directory press `poetry install`
88
* Create MongoDB database named `ir-commands`.
99
* Create collection named `commands`.
10-
* Set `DATABASE_URL` environment variable the MongoDB URL,
10+
* Set the `DATABASE_URL` environment variable the MongoDB URL,
1111
* Run it using `poetry run python src/app.py`.
1212
* In production run is recommended to use `gunicorn` see [gunicorn page](https://pypi.org/project/gunicorn/).
1313

@@ -20,10 +20,19 @@ The Server is Build with Python, with the Flask framework for the HTTP Routing,
2020
If you have a project that uses RF commands for appliances (For example, see my great project [casanet](https://github.com/casanet/casanet-server)), worry no more! this project will help with storing and fetching commands on demand.
2121
With simple RESTfull API, you will be able the get all the available devices in the system, and their known commands.
2222

23-
# stages
24-
## Stage A
25-
The DB will be close for uploading, and we will upload them manually.
26-
you will be able to get the list of all the devices and their known commands. the data will be mostly for Air-conditioning.
27-
## Stage B
28-
The DB will be open for everyone to upload their data, hopefully for other types of devices. also, the API will allow you to search the device you need with a single recording of your device-command.
29-
another expansion planned for stage B is receiving all devices commands by type of command (i.e. Turn-off, Turn-on), as a way to try to detect the type of your device.
23+
# data access & manipulation
24+
Anyone can access the API, but to manipulate the data the request need to authorized by the [remote server](https://github.com/casanet/remote-server) as a valid local user
25+
by adding an `local_server_key_header` header contains the local server certificate `mac_address:local_server_api_secret_key`.
26+
27+
To allow it, set `REMOTE_SERVER_URL` environment variable contained the remote server URL and `RF_REPOSITORY_API_KEY` with same key in the remote server to validate Rf commands validations requests, see [.env.example](./.env.example) for example.
28+
29+
# API (quick review)
30+
- GET /devices
31+
- POST /devices json=`{ brand : string, model: string, category: string, commands: object }`
32+
- PUT /devices/{brand}/{model} json=`{ brand : string, model: string, category: string }`
33+
- DELETE /devices/{brand}/{model}
34+
- GET /rf/{brand}/{model}
35+
- PUT /rf/{brand}/{model} json=`{ commands: object }`
36+
37+
38+

src/route/device_route.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def create_device_route():
1818
return resp
1919

2020

21-
@app.route('/device/<brand>/<model>', methods=['PUT'])
21+
@app.route('/devices/<brand>/<model>', methods=['PUT'])
2222
@local_server_scope()
2323
@expects_json(edit_device_schema)
2424
def set_device_route(brand: str, model: str):
@@ -27,7 +27,7 @@ def set_device_route(brand: str, model: str):
2727
return resp
2828

2929

30-
@app.route('/device/<brand>/<model>', methods=['DELETE'])
30+
@app.route('/devices/<brand>/<model>', methods=['DELETE'])
3131
@local_server_scope()
3232
def delete_device_route(brand: str, model: str):
3333
delete_device(brand=brand, model=model)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy