本文整理汇总了Python中tools.Tools.register_local方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.register_local方法的具体用法?Python Tools.register_local怎么用?Python Tools.register_local使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.Tools
的用法示例。
在下文中一共展示了Tools.register_local方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Flask
# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import register_local [as 别名]
# Initialize the Flask application
app = Flask(__name__)
## ROUTES ##
@app.route('/getdata', methods=['GET'])
def getData():
list = tools.virtual_data_sensors()
return list
@app.route('/getsensorslist', methods=['GET'])
def getSensorList():
# TODO get list from z1
return 'GetSensorsList called <-- UNIMPLEMENTED'
## MAIN
if __name__ == '__main__':
uuid = get_mac()
tools = Tools()
tools.register_local(uuid)
app.run(
host="0.0.0.0",
port=int(tools.local_port)
)
示例2: get_mac
# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import register_local [as 别名]
# sys.argv[1] has to be a .cfg file containing those info:
# [general]
# auto_external: true
# external: http://exemple.com
# port: 1234
# distant_ip: http://1.iot-pirate.appspot.com
# friendly_name: deruaz_home
if __name__ == '__main__':
# local server machine Mac address is used as an UUID
uuid = get_mac()
tools = Tools(uuid, sys.argv[1])
# param 2 --> UUID of an animal
# sensor need to have a get_json() method
# sensor need attributs name and uuid
# tools.add_sensor(Sensor_tag_virtual( 'virtual_1', '51fa8287-a719-4c1b-8177-7ec829f6e08e', 'BLE'))
tools.add_sensor(Sensor_tag_virtual( 'virtual_2', '23fa8287-a719-4c1b-8177-7ec829f6e08r', 'BLE', 0, "2015-12-05 11:03:06"))
# real sensor with TexasInstrument SensorTag
#tools.add_sensor(Sensor_tag_virtual( 'real_1', '61112222-a319-4c1b-8177-6r7ew6qr8ew7', '6Lowpan', 0, "2015-01-03 11:03:06"))
# tell to app Engine backend that data can be fetch from him
tools.register_local()
app.run(
host="0.0.0.0",
port=int(tools.local_port)
)