from flask import Flask, render_template, jsonify import meshtastic.serial_interface import meshtastic import threading import time app = Flask(__name__) node_locations = {} MY_NODE_ID = "!934f4430" # MY_NODE_NUM = 2471445552 iface = meshtastic.serial_interface.SerialInterface() # iface.nodes.clear() @app.route("/") def index(): return render_template("map.html") @app.route("/nodes") def nodes(): data = {} nodes = iface.nodes.items() for node_id, node in nodes: num = node.get('num') user = node.get('user') position = node.get('position') deviceMetrics = node.get('deviceMetrics') return jsonify({ # "myNodeNum": MY_NODE_NUM, "myNodeId": MY_NODE_ID, "nodes": dict(nodes) }) if __name__ == "__main__": app.run(host='0.0.0.0', port=8083)