Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Politecnico-Open-unix-Labs/b3api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

b3api

Server side implementation of a super-set of the SpaceAPI, keeps the informations about the hackerspace status and send them to the clients.

Can be also used as server backend for Internet of Things and domotics applications.

Usage

Run b3api on your server (e.g. localhost:8080).

It stores informations in a dictionary, to get them you can simply use a GET request

curl localhost:8080

To send data you can use a POST, but you need a token

curl -H "Content-Type: application/json" -X POST \
  -d '{"hello":"world","key":<YOUR_TOKEN_HERE>}' http://localhost:8080

To generate new tokens run newkoken.py.

Tokens can authorize writings on restricted subpath (e.g. /foo/bar) of the data dictionary, to generate this ones run:

python newtoken.py /foo/bar

Websockets

You can also use websockets:

from websocket import create_connection

ws = create_connection("ws://localhost:8080")

# receiving
print(ws.recv())

# sending
ws.send('{"hello":"world", "key":<YOUR_TOKEN_HERE>}')

ws.close()

If you keep the socket openened and use callback you will receive a diffential update every time a field is changed.

To use websockets in python install websocket-client

pip install websocket-client

For further explainations read the documentation.

License

See LICENSE file.

About

Server side for the B3 logging system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published