Created
November 26, 2017 15:29
-
-
Save sleepdefic1t/4dd64ea887deb5c6c8f08db515722c0d to your computer and use it in GitHub Desktop.
Converts raw HTML to an Arduino compatible HTML-string | cp from https://github.com/FanaHOVA/HTML2Arduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def raw2arduino(): | |
i = open("raw.html", 'r') | |
o = open("arduino.html", 'a') | |
for line in i.readlines(): | |
o.write('client.println("') | |
o.write(line.strip("\n")) | |
o.write('");\n') | |
i.close() | |
o.close() | |
print "Done!" | |
def arduino2raw(): | |
i = open("arduino.html", 'r') | |
o = open("raw.html", 'a') | |
for line in i.readlines(): | |
o.write(line[15:-3].strip('"')) | |
o.write("\n") | |
i.close() | |
o.close() | |
print "Done!" | |
if __name__ == '__main__': | |
d = raw_input("Copy the files you want to convert in this folder as 'raw.html' and 'arduino.html' \n Which conversion do you wanna do? \n 1. HTML to Arduino \n 2. Arduino to HTML\n") | |
if d == "1": | |
raw2arduino() | |
elif d == "2": | |
arduino2raw() | |
else: | |
print "Invalid input" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment