diff --git a/ForkPullSteps.txt b/ForkPullSteps.txt new file mode 100644 index 00000000..be46893d --- /dev/null +++ b/ForkPullSteps.txt @@ -0,0 +1,23 @@ +Most of what we need to do for this week can be accomplished directly in the github web interface. Here are the steps you can use to get the job done (steps 2-4 were done in class, so you can probably skip them): + +1. Log in to the github website + +2. Visit my repository for the class documentation: http://github.com/cewing/training.python_web + +3. In the top right corner of the repository listing, find the button labelled 'Fork'. Click it to fork the repository. + +4. After a short while, you'll find that you now have a copy of this repository in your own github account. Clone that to your own machine (git clone http://github.com//training.python_web.git) + +5. Complete the assignment, placing your final scripts into the 'assignments/week01/athome' directory in the clone on your local machine. + +6. Commit your changes to the repository (you'll need to 'git add' new files you create, then 'git commit' them, e.g.: + +git commit -m "introducing a client to add numbers" + +7. Push your committed changes back to your github account with 'git push origin master' + +8. Back on the github website, click on the 'Pull Request' button at the top of the page listing your fork of my repository (the copy in your account). You can write a note to me if you like when you make your pull request. + +From step 8, I'll get an email that tells me that you have made a pull request. That email will contain links to your fork of my repository. I can use that link to review the changes you've made. After I've reviewed your assignment, I'll delete the pull request because I don't actually want to pull your changes for this assignment into my repository. + +That'll be all. \ No newline at end of file diff --git a/assignments/week02/athome/http_serve1.py b/assignments/week02/athome/http_serve1.py new file mode 100644 index 00000000..d081cddf --- /dev/null +++ b/assignments/week02/athome/http_serve1.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import socket + +host = '' # listen on all connections (WiFi, etc) +port = 50000 +backlog = 5 # how many connections can we stack up +size = 1024 # number of bytes to receive at once + +## create the socket +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +# set an option to tell the OS to re-use the socket +s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + +# the bind makes it a server +s.bind( (host,port) ) +s.listen(backlog) +fin = open('tiny_html.html', 'r') +html = fin.read() +fin.close() + +while True: # keep looking for new connections forever + client, address = s.accept() # look for a connection + data = client.recv(size) + if data: # if the connection was closed there would be no data + print "received: %s, sending it back"%data + client.send(html) + client.close() \ No newline at end of file