Unlike in real Python, the indentation in a web2py view is only aesthetic. You need to clearly specify where the while
block ends by adding pass
at its end. Also note that you don't need to constantly close and open the brackets like this, you can escape all the code in only one {{ ... }}
.
{{
filename = xmlfile
fh = open(xmlfile, "r")
while True:
line = fh.readline()
print(line, end="")
pass
fh.close()
}}