I have set up a webserver with Micropython as decribed here. In the tutorial, there is an html variable that I am trying to externalize into a separate file and then read it in like so:
import codecs
with codecs.open("main.html", 'r') as f:
html = f.read()
In principle this works nicely, there is just one flaw. The html variable declaration has a variable called gpio_state inside it, like this:
html = """---html code stuff---""" + gpio_state + """---more html stuff---"""
The gpio_state variable resolves into ON or OFF when I have this in the .py file directly as intended. When the html is in a different file and imported with the above method it is read as a string instead. I see gpio_state and the """ characters in my browser.
Is it possible to import an html file with a variable in the python script?
Sorry - I probably lack some python vocabulary here and could have expressed the problem more concisely!