title: How to run Python and HTML together?
body: <p>I am trying to create a simple tool (hopefully it is simple) that uses Python and HTML to perform some basic tasks.</p>
  
  <p>I have this in Python.</p>
  
  <pre><code>#!/usr/bin/env python
  
  import cgi
  import cgitb
  
  cgitb.enable()
  
  print("Content-type: text/html\n\n")
  
  form=cgi.FieldStorage()
  
  if "language" not in form:
      print("&lt;h1&gt;No option chosen&lt;/h1&gt;")
  else:
      text=form["language"].value
      print("&lt;h1&gt;The option chosen was:&lt;/h1&gt;")
      print(text)
  </code></pre>
  
  <p>I have this in a text file, that is saved with an HTM extension.</p>
  
  <pre><code>&lt;form action="/cgi-bin/examples/dropdown.py" method="POST"&gt;
  
      My favaourite programming language is
      &lt;select name="language"&gt;
          &lt;option value="c"&gt;C&lt;/option&gt;
          &lt;option value="python"&gt;Python&lt;/option&gt;
          &lt;option value="php"&gt;PHP&lt;/option&gt;
          &lt;option value="Java"&gt;Java&lt;/option&gt;
      &lt;/select&gt;
  &lt;br&gt;
      &lt;input type="submit" value="Submit"&gt;  
      &lt;input type="reset" value="Reset"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>The HTM file gives me a simple web page that lets me select items from a drop-down menu.</p>
  
  <p><a href="https://i.stack.imgur.com/3d1Cx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3d1Cx.png" alt="enter image description here"></a></p>
  
  <p>I am trying to get Python to interact with the HTM file, so I can allow a user to concatenate between 3-4 strings together, and then click a 'submit' button to request access to a few data sets, based on a combinations of items that a user selects from the drop-down menus.</p>
  
  <p>Does this make sense?  Is this a good approach?  I'm looking at the sample code from the following URL.</p>
  
  <p><a href="http://raspberrywebserver.com/cgiscripting/web-forms-with-python.html" rel="nofollow noreferrer">http://raspberrywebserver.com/cgiscripting/web-forms-with-python.html</a></p>
  
  <p>I am using Python 3.6.</p>