Day 20 - Th, April 2, 2013

Schedule:

Note: no class on Thursday.

TCP/IP Networking

You can use this for a reference –

http://www.tutorialspoint.com/python/python_networking.htm

Take a look at the stuff under network/ in the latest cse491-webz –

This is a very simple client/server back-and-forth for TCP/IP.

Questions –

  1. How can one side of a connection know how much data remains to be read from the other side of the connection?

  2. Run the server, connect to it with the client, and then use CTRL-C to kill it. What signal does the client get?

  3. Modify the client to send a file to the server upon connection. Make sure that both sides “clean up”, that is, exit properly.

    Note:

    data = open(filename).read()
    

    to read bytes in from a file, and

    fp = open(filename, 'w')
    fp.write(data)
    fp.close()
    

    to save data to a file.

  4. Modify the server to send a file to the client as soon as the client connects. Make sure that both sides “clean up”.

  5. Modify the client to send a file containing text that the server then

    1. uppercases
    2. replaces all As with ZZs

    Note,

    s = t.replace('A', 'ZZ')
    

    will do the latter.

Templating with Jinja2, round 2

Look at the Jinja2 stuff from Day 19 - Th, Mar 28th, 2013, and grab the latest cse491-webz. Try rendering ‘test4.html’ and ‘test5.html’; look at templates/test4.html and templates/test5.html. What’s going on?

Things to try –

  • modify ‘is_tuesday’ in render.py to be True. What happens in test4.html?
  • What does the |e do (see {{ name|e }}) in test5.html? Try removing it, and load stuff in a browser.
  • Revisit test3.html. Do you understand what’s going on here?

Minute Cards

In the last 5 minutes of class, please fill out this minute card survey.

comments powered by Disqus