-
Unable to read file
Hello!! I want to read a file in order to return it from my Mobile Web Server. However,it does not read the data. I had some error that said that i didnt have permission to access the file... Here is the code
def handler(req):
from mod_python import apache
f=open('file.txt', 'w')
req.content_type='text/html'
req.write("<html>Reading")
line=f.readline()
req.write(line)
f.close()
req.write("</html>")
return apache.OK
Thanks in advance :p
-
Re: Unable to read file
Right,I solve this in other thread. Thanks to aya42. ;)
f=open('file.txt', 'r') means reading from the file.
f=open('file.txt', 'w') means writing from the file.
Here you go the code: :rolleyes:
[CODE]
def handler(req):
from mod_python import apache
f=open('file.txt', 'r') #you can read also xml,html files and so on...
req.content_type='text/plain' #if you want to read xml, req.content_type='text/xml'
req.write("<html>Reading")
line=f.readline()
req.write(line)
f.close()
req.write("</html>")
return apache.OK[/CODE]
Cheers!