Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
95e4b2a
week 1 homeworks
ericchou-python Jan 10, 2013
65ef03a
week 1 bonus homeworks
ericchou-python Jan 10, 2013
8a2c4f0
week01 assignment and bonus
Jan 14, 2013
5ab9aa8
Merge branch 'master' of https://github.com/cewing/training.python_web
Jan 14, 2013
0555421
Merge branch 'master' of https://github.com/cewing/training.python_web
Jan 16, 2013
aca33a2
add all http_serv1.py to http_serv5.py
Jan 19, 2013
0b1a844
week 02 at home assignments
Jan 19, 2013
a6597d3
modify README
Jan 19, 2013
1b4a258
Merge branch 'master' of https://github.com/cewing/training.python_web
Jan 19, 2013
5e2d5a9
GeoIP and Google Map mash up
Jan 20, 2013
19712e1
Merge branch 'master' of https://github.com/cewing/training.python_web
Jan 23, 2013
40c01c5
Week03 MashUp Homeworks:
Jan 24, 2013
f950d28
Adding simple webServer.py, simple static html and simple form to week04
Jan 26, 2013
004457a
Week 04 WSGI assignment
Jan 26, 2013
a8730a0
Merge branch 'master' of https://github.com/cewing/training.python_web
Jan 30, 2013
e00a789
Merge branch 'master' of https://github.com/cewing/training.python_web
Feb 2, 2013
360d09a
Merge branch 'master' of https://github.com/cewing/training.python_web
Feb 4, 2013
bc8f156
Merge branch 'master' of https://github.com/cewing/training.python_web
Feb 6, 2013
f9e54d8
Week05 homework with README
Feb 10, 2013
ef4981c
Merge branch 'master' of https://github.com/cewing/training.python_web
Feb 15, 2013
815c6b0
Add Week 6 UW-Django Djangor
Feb 17, 2013
76d55c7
Merge branch 'master' of https://github.com/cewing/training.python_web
Feb 27, 2013
fa8436e
Merge branch 'master' of https://github.com/cewing/training.python_web
Mar 8, 2013
8ddfd55
new file: django/README
Mar 8, 2013
73c463e
Update README.md
ericchou-python Mar 8, 2013
3fe2ea8
new file: week10_django.tgz
Mar 13, 2013
f0ddfe0
modified: README
Mar 13, 2013
8d538e0
Merge branch 'master' of https://github.com/ericchou-python/training.…
Mar 13, 2013
e54c390
modified: README
Mar 13, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions 30 assignments/week01/athome/sum_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# use system argument 1 and 2 to specificy the two numbers
#

import socket
import sys

# Create a TCP/IP socket
client_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
server_address = ('localhost', 50000)
#server_address = ('208.85.148.52', 50000) #VM public IP
client_connect.connect(server_address)

try:
# Send data
num1 = sys.argv[1]
num2 = sys.argv[2]
msg = num1.strip() + " " + num2.strip()
client_connect.sendall(msg)

# print the response
response = client_connect.recv(4096)
print response

finally:
# close the socket to clean up
client_connect.close()
30 changes: 30 additions & 0 deletions 30 assignments/week01/athome/sum_client_bonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# use system argument 1 and 2 to specificy the two numbers
#

import socket
import sys

# Create a TCP/IP socket
client_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
#server_address = ('localhost', 50000)
server_address = ('208.85.148.52', 50000) #VM public IP
client_connect.connect(server_address)

try:
# Send data
num1 = sys.argv[1]
num2 = sys.argv[2]
msg = num1.strip() + " " + num2.strip()
client_connect.sendall(msg)

# print the response
response = client_connect.recv(4096)
print response

finally:
# close the socket to clean up
client_connect.close()
40 changes: 40 additions & 0 deletions 40 assignments/week01/athome/sum_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

import socket
import sys

# Create a TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = ('localhost', 50000)
server_socket.bind(server_address)

# Listen for incoming connections
server_socket.listen(1)

while True:
# Wait for a connection
connection, client_address = server_socket.accept()

try:
print 'Connection from: ', client_address[0], ' port ', client_address[1]
while True:
# Receive the data and send it back
data = connection.recv(80)
if data:
result = data.split()
num1, num2 = result[0], result[1]
print "first number is %s, second number is %s" % (num1, num2)
sendBack = int(num1) + int(num2)
print "sending result of %s back" % str(sendBack)
connection.sendall(str(sendBack))
else:
break

finally:
# Clean up the connection
connection.close()

server_socket.close()

41 changes: 41 additions & 0 deletions 41 assignments/week01/athome/sum_server_bonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

import socket
import sys

# Create a TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
#server_address = ('localhost', 50000)
server_address = ('208.85.148.52', 50000) #VM public IP
server_socket.bind(server_address)

# Listen for incoming connections
server_socket.listen(1)

while True:
# Wait for a connection
connection, client_address = server_socket.accept()

try:
print 'Connection from: ', client_address[0], ' port ', client_address[1]
while True:
# Receive the data and send it back
data = connection.recv(80)
if data:
result = data.split()
num1, num2 = result[0], result[1]
print "first number is %s, second number is %s" % (num1, num2)
sendBack = int(num1) + int(num2)
print "sending result of %s back" % str(sendBack)
connection.sendall(str(sendBack))
else:
break

finally:
# Clean up the connection
connection.close()

server_socket.close()

30 changes: 30 additions & 0 deletions 30 assignments/week01/lab/sum_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# use system argument 1 and 2 to specificy the two numbers
#

import socket
import sys

# Create a TCP/IP socket
client_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
server_address = ('localhost', 50000)
#server_address = ('208.85.148.52', 50000) #VM public IP
client_connect.connect(server_address)

try:
# Send data
num1 = sys.argv[1]
num2 = sys.argv[2]
msg = num1.strip() + " " + num2.strip()
client_connect.sendall(msg)

# print the response
response = client_connect.recv(4096)
print response

finally:
# close the socket to clean up
client_connect.close()
30 changes: 30 additions & 0 deletions 30 assignments/week01/lab/sum_client_bonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# use system argument 1 and 2 to specificy the two numbers
#

import socket
import sys

# Create a TCP/IP socket
client_connect = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
#server_address = ('localhost', 50000)
server_address = ('208.85.148.52', 50000) #VM public IP
client_connect.connect(server_address)

try:
# Send data
num1 = sys.argv[1]
num2 = sys.argv[2]
msg = num1.strip() + " " + num2.strip()
client_connect.sendall(msg)

# print the response
response = client_connect.recv(4096)
print response

finally:
# close the socket to clean up
client_connect.close()
40 changes: 40 additions & 0 deletions 40 assignments/week01/lab/sum_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python

import socket
import sys

# Create a TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = ('localhost', 50000)
server_socket.bind(server_address)

# Listen for incoming connections
server_socket.listen(1)

while True:
# Wait for a connection
connection, client_address = server_socket.accept()

try:
print 'Connection from: ', client_address[0], ' port ', client_address[1]
while True:
# Receive the data and send it back
data = connection.recv(80)
if data:
result = data.split()
num1, num2 = result[0], result[1]
print "first number is %s, second number is %s" % (num1, num2)
sendBack = int(num1) + int(num2)
print "sending result of %s back" % str(sendBack)
connection.sendall(str(sendBack))
else:
break

finally:
# Clean up the connection
connection.close()

server_socket.close()

41 changes: 41 additions & 0 deletions 41 assignments/week01/lab/sum_server_bonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

import socket
import sys

# Create a TCP/IP socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
#server_address = ('localhost', 50000)
server_address = ('208.85.148.52', 50000) #VM public IP
server_socket.bind(server_address)

# Listen for incoming connections
server_socket.listen(1)

while True:
# Wait for a connection
connection, client_address = server_socket.accept()

try:
print 'Connection from: ', client_address[0], ' port ', client_address[1]
while True:
# Receive the data and send it back
data = connection.recv(80)
if data:
result = data.split()
num1, num2 = result[0], result[1]
print "first number is %s, second number is %s" % (num1, num2)
sendBack = int(num1) + int(num2)
print "sending result of %s back" % str(sendBack)
connection.sendall(str(sendBack))
else:
break

finally:
# Clean up the connection
connection.close()

server_socket.close()

10 changes: 10 additions & 0 deletions 10 assignments/week02/athome/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Week 02 Home Assignment

1. build from http_serv5.py from lab, copy to my_http_serv5.py
2. created format_directory method to format links
3. walk thru images subdirectory and web direction, make them html clickable
4. the temp file is called result.html, the function reads it back and return the result
5. the directory walk will skip this temp file
6. to make make_time.py return HTML page, use subprocess to dump the result in a separate file
7. found that I need to use time.sleep() to allow system enough time to execute python file

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.