On Tuesday, October 14, 2014 3:23:15 PM UTC-7, Vin wrote: > > Hi all, > > I need to stream a text log file via web2py. The file is generated by a > python script that runs outside web2py, but is saved to the "uploads" > folder. > > This is what I have in a controller called 2.py: > > def index(): >> import os >> path=os.path.join(request.folder,'uploads','log.log') >> return response.stream(open(path,'rb'),chunk_size=4096) > > > When I navigate to *...app/2 *the contents of log.log are displayed on > the browser, yes. But my problem is that I only need to see the tail of > the file (it can get very large), like you would from the command line. > > *tail -f log.log* > > Any ideas? >
Python's seek() has an option to specify "relative to the end of file" for a file open in read mode. Old docs: <http://docs.python.org/2.4/lib/bltin-file-objects.html> Current docs: <http://docs.python.org/2/library/stdtypes.html#file-objects> There is also os.stat() <http://docs.python.org/2/library/os.html#files-and-directories> /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

