Great question — answering as the UphillTech team:
You need to get all the results in a variable, generate your html then return so user can see it. let's try: from flask import Flask import wmi app = Flask(__name__) ip = ['server1', 'server2', 'server3', 'server4', 'server5'] user = "username" password = "password" append_services = [] words = 'win32' @app.route("/") def service_status(): results = [] # Temp for result to return to html for a in ip: global append_services print('\n'+a+'\n') c = wmi.WMI(a, user=user, password=password) get_names = c.Win32_Service() for y in get_names: convert = str(y.Name) append_services.append(convert) append_services = \ [w for w in append_services if w.startswith(words)] for l in append_services:...
Full answer by Phung Duy Phong: https://stackoverflow.stackexchange.com/a/44198122 (CC BY-SA 3.0).
Need it done for your business? UphillTech.