From 9a958a549df8fac73e2042ae7e2208e0de2fe718 Mon Sep 17 00:00:00 2001 From: edetn Date: Sun, 13 Jan 2013 14:40:15 -0800 Subject: [PATCH 1/3] Updated the echo_server file --- assignments/week01/lab/echo_server.py | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/assignments/week01/lab/echo_server.py b/assignments/week01/lab/echo_server.py index e2c52fc6..bdf449d4 100644 --- a/assignments/week01/lab/echo_server.py +++ b/assignments/week01/lab/echo_server.py @@ -1,19 +1,45 @@ import socket import sys +# Create a function to sum the numbers from the users +def num_sum(msg): + """ This function resturns the sum of a list of integers """ + num_sum = 0 + for i in range(len(msg)): + num_sum += int(msg[i]) + return num_sum + # Create a TCP/IP socket +echo_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Bind the socket to the port server_address = ('localhost', 50000) +print >>sys.stderr, 'starting up on %s port %s' % server_address +echo_server.bind(server_address) # Listen for incoming connections +echo_server.listen(1) while True: # Wait for a connection - + print >>sys.stderr, 'waiting for a connection' + connection, client_address = echo_server.accept() try: - # Receive the data and send it back + print >>sys.stderr, 'connection from', client_address + + # Receive the data + message = connection.recv(1024) + data = message.split(',') + print >>sys.stderr, 'received "%s"' % data + + # Compute the sum + return_data = str(num_sum(data)) + + # Send the data back to the client + print >>sys.stderr, 'sending return_data back to the client', return_data + connection.sendall(return_data) finally: # Clean up the connection + connection.close() From 5a420cfe222cc07bddb10a7f69adc2c0eda094ff Mon Sep 17 00:00:00 2001 From: edetn Date: Sun, 13 Jan 2013 14:48:31 -0800 Subject: [PATCH 2/3] updated echo_client --- assignments/week01/lab/echo_client.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/assignments/week01/lab/echo_client.py b/assignments/week01/lab/echo_client.py index b8898436..023bfba0 100644 --- a/assignments/week01/lab/echo_client.py +++ b/assignments/week01/lab/echo_client.py @@ -1,16 +1,34 @@ import socket import sys +# Create a function for requesting numbers from the users +def get_num(): + """ This function takes two numbers 'x' and 'y' and returns a string """ + list_num = raw_input(' Please enter two comma seperated numbers > ') + return list_num + # Create a TCP/IP socket +echo_client = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # Connect the socket to the port where the server is listening server_address = ('localhost', 50000) +echo_client.connect(server_address) try: + # Send data - message = 'This is the message. It will be repeated.' + message = get_num() + print >>sys.stderr, 'sending "%s"' % message + echo_client.sendall(message) + + # receive the response from the server + data = echo_client.recv(1024) # print the response + print >>sys.stderr, 'Computed sum of %s is "%s"' % (message, data) finally: # close the socket to clean up + print >>sys.stderr, 'closing socket' + echo_client.close() + From 3fceb6b9247671acc7513a6d652c011482e8e604 Mon Sep 17 00:00:00 2001 From: edetn Date: Tue, 5 Feb 2013 10:27:56 -0800 Subject: [PATCH 3/3] week04-readme README 1. Select the following link - runs book1_cgi.py http://block647062-yym.blueboxgrid.com/cgi-bin/book1_cgi.py 2. To display the database book index - runs book2_cgi.py Click the hyper link INDEX OF THE BOOK DATABASE 3. This will display an Index of books with their title Click on the title and it will display the page 4. Source Code is all contained in assignments/week04/athome/src the following files comprise the code bookdb.py book1_cgi.py book2_cgi.py book2_wsgi_id1.py book2_wsgi_id2.py book2_wsgi_id3.py book2_wsgi_id4.py book2_wsgi_id5.py --- assignments/week04-readme.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 assignments/week04-readme.txt diff --git a/assignments/week04-readme.txt b/assignments/week04-readme.txt new file mode 100644 index 00000000..1068d743 --- /dev/null +++ b/assignments/week04-readme.txt @@ -0,0 +1,21 @@ +README + +1. Select the following link - runs book1_cgi.py +http://block647062-yym.blueboxgrid.com/cgi-bin/book1_cgi.py + +2. To display the database book index - runs book2_cgi.py +Click the hyper link INDEX OF THE BOOK DATABASE + +3. This will display an Index of books with their title +Click on the title and it will display the page + +4. Source Code is all contained in assignments/week04/athome/src +the following files comprise the code +bookdb.py +book1_cgi.py +book2_cgi.py +book2_wsgi_id1.py +book2_wsgi_id2.py +book2_wsgi_id3.py +book2_wsgi_id4.py +book2_wsgi_id5.py