I put together the following script that i would like to return the "Hello World !('192.168.0.162', 48344)bob" when in my browser i have
server:8081/?first_name=bob
however when i run the following program it returns Hello World !('192.168.0.162', 48344)None
#!/usr/bin/python
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
import cgi, cgitb
x = "1"
PORT_NUMBER = 8081
cgitb.enable()
#This class will handles any incoming request from
#the browser
class myHandler(BaseHTTPRequestHandler):
#Handler for the GET requests
def do_GET(self):
form = cgi.FieldStorage()
first_name = form.getvalue('first_name')
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
# Send the html message
self.wfile.write("Hello World !")
self.wfile.write(self.client_address)
self.wfile.write(first_name)
return
try:
#Create a web server and define the handler to manage the
#incoming request
server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ' , PORT_NUMBER
#Wait forever for incoming htto requests
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down the web server'
server.socket.close()
What is wrong?