def load_config(config): path = os.path.abspath(config) l = [] with open(path, "r") as f: for line in f: if line[0] == "#": continue l.extend(line.split()) set_args(l) return 0 set_args(sys.argv[1:]) if config != None: load_config(config) hub.log = Log(print_enabled=print_enabled) hub.log.log("Starting up HUB webserver") init_db() updates = {"nodes": []} node_updates = updates.get("nodes") #Start pubnub for accounts for account in Account.get_all(): if account.account_name == 'wink': wink.subscribe_devices(account) app.run(host=host, debug=debug, port=port, threaded=threaded)
from os import environ as env from hub import app if __name__ == '__main__': app.run(host="0.0.0.0", port=env.get('PORT', 4000))
from hub import app if __name__ == '__main__': app.run(debug=True) # ++=========================================++ # || KKSI AI - SMKN 4 Bandung - Smart Helper || # ||-----------------------------------------|| # || Pembina: || # || Ibu Tyas || # || Anggota(Berdasarkan Alphabet): || # || Aldo Fakhry || # || Firdaus Haqiqi || # || Muhammad Azmi || # ||-----------------------------------------|| # || Terimakasih Pada: || # || # Sentdex || # || # Pandas Documentation || # || # Diwas Padley || # || # Stack Overflow || # || # Our World In Data || # ++=========================================++
l.extend(line.split()) set_args(l) return 0 set_args(sys.argv[1:]) if config != None: load_config(config) hub.log = Log(print_enabled=print_enabled) hub.log.log("Starting up HUB webserver") hub.Webapi = WebAPI(hub.WEB_API_URL, hub.WEB_API_KEY, hub.log) hub.Webapi.sign_in() init_db() updates = {"nodes": []} node_updates = updates.get("nodes") for printer in Printer.get_all(): id = printer.id t = PrinterCollector(id, hub.Webapi, hub.log) t.start() hub.printer_listeners.add_thread(id, t) for node in Node.get_all(): id = node.id if node.printer_id == None: node_updates.append(id) t = NodeCollector(id, hub.Webapi, hub.log) t.start() hub.node_listeners.add_thread(id, t) hub.Webapi.update_nodes(updates) app.run(host=host, debug=debug, port=port,threaded=threaded)
import os from hub import app, init_db from hub.background_update import CheckThermostatsConnectivity # initialize database if it doesn't exist if not os.path.isfile(app.config['DATABASE']): init_db() # start background thread to periodicaly check connection with each registered # thermostat and mark as offline if can't be reached CheckThermostatsConnectivity(interval=120, database=app.config['DATABASE']) app.run(host='0.0.0.0', port=3000)