stream logfile from django
a guest Jun 16th, 2016 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- def stream_file(request, b64fname):
- def follow(fname):
- fd = open(fname, 'r')
- while True:
- line = fd.readline()
- if not line:
- yield line + "<br/>"
- yield " " * 1024 # Encourage browser to render incrementally
- fname = base64.urlsafe_b64decode(b64fname).decode('utf-8')
- response = StreamingHttpResponse(
- return response
RAW Paste Data