data-uri-b64encoder.py is a python script to generate a base64 data-uri. The idea behind this script was inpired by the Jose Jesus Perez Aguinaga's 'One line browser notepad' tip.
data-uri-b64encoder.py text/html <myhtmlfile.html>
data-uri-b64encoder.py is a python script to generate a base64 data-uri. The idea behind this script was inpired by the Jose Jesus Perez Aguinaga's 'One line browser notepad' tip.
data-uri-b64encoder.py text/html <myhtmlfile.html>
| #!/usr/bin/env python | |
| import base64 | |
| import sys | |
| import os | |
| if len(sys.argv) != 3: | |
| print "USAGE: %s <data-type> <file>" % sys.argv[0] | |
| exit(1) | |
| file = sys.argv[2] | |
| if not os.path.exists(file): | |
| print "ERROR: Please specify an existing file" | |
| exit(2) | |
| print "data:%s;base64,%s" % (sys.argv[1], base64.b64encode(open(sys.argv[2], "r").read())) |