Skip to content

Instantly share code, notes, and snippets.

@fdanelyan
Created April 18, 2014 07:34
Show Gist options
  • Save fdanelyan/11029571 to your computer and use it in GitHub Desktop.
Save fdanelyan/11029571 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)
@DiHand79
Copy link

DiHand79 commented Oct 7, 2019

thanks

@faizankhan82
Copy link

Thanks for this code.

@Vulpes-91
Copy link

Thanks man, this one did me a real favor in my pet project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment