×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    52

    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

  2. #2
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    52

    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:

    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
    Cheers!

Similar Threads

  1. Error : Cannot find file : for DUMMIES
    By PACALA_BA in forum Symbian
    Replies: 7
    Last Post: 2008-07-06, 13:18
  2. Problem with pyobfuscate
    By JOM in forum Symbian
    Replies: 3
    Last Post: 2008-06-20, 22:47
  3. Sent a file, and read it
    By fuatsungur in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-02-06, 18:00
  4. Unable to read file error
    By gpalvia in forum Digital Rights Management & Content Downloading
    Replies: 0
    Last Post: 2007-11-21, 07:46
  5. Unable to read file DRM forward lock
    By gpalvia in forum Symbian
    Replies: 0
    Last Post: 2007-11-21, 03:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×