title: Generate html document with images and text within python script (without servers if possible)
body: <p>How can I generate HTML containing images and text, using a template and css, in python?</p>
  
  <p>There are few similar questions on stackoverflow (e.g.: <a href="https://stackoverflow.com/questions/6748559/generating-html-documents-in-python">Q1</a>, <a href="https://stackoverflow.com/questions/98135/how-do-i-use-django-templates-without-the-rest-of-django">Q2</a>, <a href="https://stackoverflow.com/questions/16523939/how-to-write-and-save-html-file-in-python">Q3</a>) but they offer solutions that (to me) seem overkill, like requiring servers (e.g. genshi).</p>
  
  <p>Simple code using <code>django</code> would be as follows:</p>
  
  <pre><code>from django.template import Template, Context
  from django.conf import settings
  settings.configure() # We have to do this to use django templates standalone - see
  # https://stackoverflow.com/questions/98135/how-do-i-use-django-templates-without-the-rest-of-django
  
  # Our template. Could just as easily be stored in a separate file
  template = """
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Template {{ title }}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Body with {{ mystring }}.
  &lt;/body&gt;
  &lt;/html&gt;
  """
  
  t = Template(template)
  c = Context({"title": "title from code",
               "mystring":"string from code"})
  print t.render(c)
  </code></pre>
  
  <p>(From here: <a href="https://stackoverflow.com/questions/6748559/generating-html-documents-in-python">Generating HTML documents in python</a>)</p>
  
  <p>This code produces an error, supposedly because I need to set up a backend:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;input&gt;", line 17, in &lt;module&gt;
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/template/base.py", line 184, in __init__
      engine = Engine.get_default()
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/django/template/engine.py", line 81, in get_default
      "No DjangoTemplates backend is configured.")
  django.core.exceptions.ImproperlyConfigured: No DjangoTemplates backend is configured.
  </code></pre>
  
  <p>Is there a simple way to have a template.html and style.css and a bunch of images, and use data in a python script to replace placeholders in the template.html without having to set up a server?</p>