def run_server(): db.init_data() db.load_to_file() player_event = Event() thread_player = Player(player_event) thread_player.play_current_song() thread_player.setDaemon(True) thread_player.start() down_event = Event() thread_down = Downloader(down_event) thread_down.setDaemon(True) thread_down.start() notify_event = Event() thread_notify = Notify(notify_event) thread_notify.setDaemon(True) thread_notify.start() maintain_event = Event() thread_maintain = Maintain(maintain_event) thread_maintain.setDaemon(True) thread_maintain.start() run(host='0.0.0.0', port=80, server=PasteServer)
tof.start() elif action == 'off': tof.stop() elif action == 'get': val = tof.range elif action == 'status': val = tof.get_status() else: val = "Invalid action" return {"value": val}, 200 @app.route('/favicon.ico') def favicon(): return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon') if __name__ == '__main__': host_name = socket.gethostbyname(socket.gethostname()) logger.info("machine host_name[" + host_name + "]") print(host_name + "[" + host_name[0: 3] + "]") if host_name[0: 3] == "192" or host_name[0: 3] == "127": host_name = ip else: host_name = "localhost" logger.info(f"app host_name[{host_name}]") tof.start() notify.start() app.run(host=host_name, port=port)