{{extend 'layout.html'}}
{{import xml.etree.ElementTree as ET}}
<h1>
This is a Stations detail page
</h1>
{{filename = xmlfile}}
{{fh = open(filename, "r")}}
{{while True:}}
{{line = fh.readline()}}
{{print(line, end="")}}
{{fh.close()}}
{{=BEAUTIFY(response._vars)}}
The above code is showing "missing "pass" in view" error in web2py. Not sure why this error is showing up
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()
}}
More informations about web2py views here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With