Guest User

Untitled

a guest
Feb 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. # works for werkzerg, not for gunicorn
  2. @expose('/qrcode/<string:text>')
  3. @has_access
  4. def qrcode(self, text):
  5. qr = qrcode.QRCode(
  6. version=4,
  7. error_correction=qrcode.constants.ERROR_CORRECT_H,
  8. box_size=10,
  9. border=1)
  10. qr.add_data(text)
  11. img = qr.make_image()
  12.  
  13. byte_io = BytesIO()
  14. img.save(byte_io, 'PNG')
  15. byte_io.seek(0)
  16.  
  17. return send_file(byte_io, mimetype="image/png")
  18.  
  19. 2018-02-22 16:27:52,377:ERROR:gunicorn.error:Error handling request
  20. Traceback (most recent call last):
  21. File "/usr/lib/pymodules/python2.7/gunicorn/workers/sync.py", line 102, in handle_request
  22. resp.write_file(respiter)
  23. File "/usr/lib/pymodules/python2.7/gunicorn/http/wsgi.py", line 285, in write_file
  24. fileno = respiter.filelike.fileno()
  25. UnsupportedOperation: fileno
Add Comment
Please, Sign In to add comment