@app.route('/drip')
def drip():
 args = CaseInsensitiveDict(request.args.items())
 duration = float(args.get('duration', 2))
 numbytes = min(int(args.get('numbytes', 10)), ((10 * 1024) * 1024))
 code = int(args.get('code', 200))
 pause = (duration / numbytes)
 delay = float(args.get('delay', 0))
 if (delay > 0):
  time.sleep(delay)
 def generate_bytes():
  for i in xrange(numbytes):
   (yield u'*'.encode('utf-8'))
   time.sleep(pause)
 response = Response(generate_bytes(), headers={'Content-Type': 'application/octet-stream', 'Content-Length': str(numbytes)})
 response.status_code = code
 return response

@ app . route ( '/drip' ) def drip ( ) : args = CaseInsensitiveDict ( request . args . items ( ) ) duration = float ( args . get ( 'duration' , 2 ) ) numbytes = min ( int ( args . get ( 'numbytes' , 10 ) ) , ( ( 10 * 1024 ) * 1024 ) ) code = int ( args . get ( 'code' , 200 ) ) pause = ( duration / numbytes ) delay = float ( args . get ( 'delay' , 0 ) ) if ( delay > 0 ) : time . sleep ( delay ) def generate_bytes ( ) : for i in xrange ( numbytes ) : ( yield u'*' . encode ( 'utf-8' ) ) time . sleep ( pause ) response = Response ( generate_bytes ( ) , headers = { 'Content-Type' : 'application/octet-stream' , 'Content-Length' : str ( numbytes ) } ) response . status_code = code return response
drips data over a duration after an optional initial delay .