HTML Wrapper in Python

The HTML wrapper module can be called in another program to display its output within HTML/CSS. Or it could be modified to pull in a master HTML template (such as index.html), concatenate new body content, and create a new HTML file, which could simply be uploaded to the server.

import webbrowser

def oberlinfo(x):
    #Places whatever object x is into oberl.info's HTML design,
    #writes the entire HTML file,
    #and automatically opens it.


    str = "<!DOCTYPE html><html><head><title>oberl.info</title><meta name=\"description\" content=\"oberl.info: Content creation by John Oberlin.\"><!--pyI head--><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><link rel=\"shortcut icon\" href=\"http://oberl.info/images/ob.ico\"><link href=\"https://fonts.googleapis.com/css?family=Montserrat|Ubuntu:700\" rel=\"stylesheet\"><link rel=\"stylesheet\" href=\"http://oberl.info/stylesheet.css\" type=\"text/css\"><!--pyO--></head><body><div class=\"main\"><!--pyI menu--><div onclick=\"myFunction()\" class=\"dropdown\"><div class=\"dropdown logo\"></div><div id=\"myDropdown\" class=\"dropdown-content\"><a href=\"http://oberl.info/john-oberlin.html\">John Oberlin</a><a href=\'http://oberl.info/freelance-writer-editor.html\'>Freelance Writer and Editor</a><a href=\'http://oberl.info/seo-strategies.html\'>SEO Strategies</a><a href=\"http://oberl.info/coding.html\"> Coding</a><a href=\'https://twitter.com/johnpoberlin\'>Twitter</a><a href=\'https://portal.hostgator.com/\' target=\"_blank\">Portal</a></div></div><!--pyO-->"


    str += "<h1>Py HTML Wrapper</h1>" + x


    str += "<!--pyI script--><script>/* When the user clicks on the button, toggle between hiding and showing the dropdown content */  function myFunction() {document.getElementById(\"myDropdown\").classList.toggle(\"show\"); } // Close the dropdown menu if the user clicks outside of it  window.onclick = function(event) {    if (!event.target.matches(\'.dropdown\')) {var dropdowns = document.getElementsByClassName(\"dropdown-content\"); var i; for (i = 0; i < dropdowns.length; i++){var openDropdown = dropdowns[i]; if (openDropdown.classList.contains(\'show\')) {openDropdown.classList.remove(\'show\');}}}}</script><!--pyO--></body></html>"


    with open("oberlinfo-generator.html","w") as f:
        f.write(str)


    url = "oberlinfo-generator.html"
    webbrowser.open(url)