Monday, February 1, 2016

W4D1 - Local Web Server, regex, and madness

Today we played with using a simple python script (handed to us) to run a local web server.  It gave us a chance to see a "GET" request and to do some simple string parsing using real info.  Also: super-basic templates (dynamically replace "###Title###" in an html file with "My Page Title" as the web server sends a GET request for the page) and using a function lookup dictionary to have a function return the relevant html string in response.

The last exercise is what kept me up until 11 (on a school night!).  Using regex to pull up the relevant function based on match to the GET request.  Even with the regex patterns pre-loaded, it was a challenge since I've only every done a copy-paste from a stackoverflow thread (with a little modification on my part).  Understanding the output from a re.match function and routing that output to a function was...interesting.  I'm not sure if it's my unfamiliarity that makes it so hard, or if I'm just missing something really obvious.

I've wanted to learn regex better for some time.  I played around with Learn Regex the Hard Way.  I suspect I'll have to come back after boot camp to really work with it.  Or maybe I can do the recommended one exercise a day while I'm here to at least get started.  It's such a powerful tool!  Plus, I'm fascinated by patterns so the thought of a mini-language devoted to describing patterns is a real lure.

In the mean time, I went to the tutorials point page and figured out enough to work through the homework.


No comments:

Post a Comment