I'm wanting to run a very simply python based server in a windows environment, to test CGI scripts. I want to do this in windows, but run ultimately in a unix environment. So far, I have a simple server, and a simple program. When I go to the site, I am seeing a blank page, with nothing in the source, and I can't figure out what's going on.
Server
from http.server import HTTPServer, CGIHTTPRequestHandler
class Handler(CGIHTTPRequestHandler):
cgi_directories = ["/cgi-bin"]
PORT = 8080
httpd = HTTPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
httpd.serve_forever()
App:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cgi, cgitb
form = cgi.FieldStorage()
# Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
print ("Content-type:text/html\r\n\r\n")
print ("<html>")
print ("<head>")
print ("<title>Hello - Second CGI Program</title>")
print ("</head>")
print ("<body>")
print ("<h2>Hello %s %s</h2>" % (first_name, last_name))
print ("</body>")
print ("</html>")
I go to the program in my web browser, and I'm getting a downloadable output, with it being the name of the file. It appears the file has executed, but I'm not getting a valid web site. What am I doing wrong?