python - Access files from web.py urls -


i'm using web.py small project , have files want user able access in /files directory on server. can't seem find how return file on request can't work how this.

exactly want is:

urls = ('/files/+', 'files')  class files:    def get(self)      #return file 

is there simple way return file request?

playing around came webpy method:

def get(self):     request = web.input( path=none )     getpath = request.path     if os.path.exists( getpath ):         getfile = file( getpath, 'rb' )         web.header('content-type','application/octet-stream')         web.header('content-transfer-encoding','base64')          return base64.standard_b64encode( getfile.read( ) )     else:         raise web.notfound( ) 

other respondants correct when advise consider security implications. in case include code administrative web service (should be!) available within our internal lan.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -