Commit 05898f0d authored by zwarag's avatar zwarag

some tries, not very better

parent 0bff6759
......@@ -16,8 +16,6 @@ host = "localhost"
port = 1883
keepalive = 60 # seconds
nodes = Nodes()
def on_connect(client, userdata, flags, rc):
print("[Index] con: Connected with result code "+str(rc))
client.subscribe("#") # hashtag means subscribe to all channels, no filtering is done here.
......@@ -29,12 +27,13 @@ def on_message(client, userdata, msg):
def handle_register(payload):
node = Node(payload)
print(json.dumps(nodes.get(), indent = 4))
print("starting register")
#print(json.dumps(Nodes.get(), indent = 4))
def hello_world():
return 'Hello World!'
return 'Welcome to API. This is a REST Service.'
api.add_resource(Nodes, '/nodes');
from flask_restful import Resource
from json import dumps
from pprint import pprint
class Nodes(Resource):
......@@ -7,9 +8,14 @@ class Nodes(Resource):
self.nodes = {}
def add(self, node):
print("whad up")
self.nodes[] = node
print("[Nodes] Added node with id " +
def get(self):
return dumps(self.nodes)
return self.nodes
def put(self, node):
add(self, node)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment