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:
- continue
- yield line + "<br/>"
- yield " " * 1024 # Encourage browser to render incrementally
- fname = base64.urlsafe_b64decode(b64fname).decode('utf-8')
- response = StreamingHttpResponse(
- follow(fname),
- content_type='text/html'
- )
- return response
Add Comment
Please, Sign In to add comment