Trying to return String using Flask

I was trying to return a string using render_template, but it’s only returning the else statement. But it’s working when I’m trying to print in the console. But not when I’m trying to use in jinja.

 def healthchecker():
   # health = ""
   for key,value in raw.items():
     if 'properties' in value:
        health = "Yes"
        health = "None"                                               

   return health                                         
 return render_template('portlist.html', data = raw, health = healthchecker())


Instead of passing the function to the template – you could pass only the dictionary. Then you could easily use it and iterate through it using jinja in your html file.

return render_template('portlist.html', data=raw)

Also, for PEP 8, avoid spaces around equal signs when assigning keyword arguments.