I´m trying to write HTML code using python and execute it from browser. Here is my code:
import webbrowser
f = open('image.html','w')
message = """<html>
<head></head>
<body><img src="URL"></body>
</html>"""
f.write(message)
f.close()
filename = 'file:///home/pi/' + 'image.html'
webbrowser.open_new_tab(filename)
Simple code, works like a charm!
Now I want to make little ¨UI¨, so that user will be able to input the URL. So my question is, can I put Python Variable into the HTML code instead of URL? for example:
a = ¨webpage.com/image.jpg¨
...
<img src="a">
...
For sure, I know that the syntax is super wrong, I just wanted to give you an example of what I´m trying to achieve. cheers!