Skip to content

Instantly share code, notes, and snippets.

@DiHand79
Forked from fdanelyan/generate_html.py
Created October 7, 2019 22:34
Show Gist options
  • Save DiHand79/44c38b42a1f6b1aa9a82cb0710d3ff5f to your computer and use it in GitHub Desktop.
Save DiHand79/44c38b42a1f6b1aa9a82cb0710d3ff5f to your computer and use it in GitHub Desktop.
Generate HTML from python and open it on default browser
# write-html.py
import webbrowser
import os
print ()
f = open('helloworld.html','w')
message = """<html>
<head></head>
<body><p>Hello World!</p></body>
</html>"""
f.write(message)
f.close()
#Change path to reflect file location
filename = 'file:///'+os.getcwd()+'/' + 'helloworld.html'
webbrowser.open_new_tab(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment