#!C:\Python27\python

import os
import sys
import cgi
import cgitb 

#if (REQUEST_METHOD == "POST"):

form = cgi.FieldStorage()

#print repr(form)

# Get data from fields
if form.getvalue('position'):
    position = form.getvalue('position')
else:
    position = "NOT SET"
   
with open('opened.txt', 'w') as file_:
    file_.write(position)

print "Content-type:text/html\r\n"
print "<html>"
print "<head>"
print "<title>Radio - Fourth CGI Program</title>"
print "</head>"
print "<body>"
print "<h2> Position is %s</h2>" % position
print "</body>"
print "</html>"

#if form.has_key("open"):
#  
#    #print file_
#
#if form.has_key("close"):
#  with open('opened.txt', 'w') as file_:
#    file_.write("CLOSE")
#    #print file_
#
#    #print file_
#  #print form.getvalue("open")
#  #with open('opened.txt', 'r') as file_:
#    #print file_
#
##GET={}
##args=os.getenv("QUERY_STRING").split('&')
#
##for arg in args: 
##  t=arg.split('=')
##  if len(t)>1: k,v=arg.split('='); GET[k]=v