![]() | Ned Batchelder : Blog | Code | Text | Site Python: batteries included » Home : Blog : March 2002 |
Python: batteries includedWednesday 13 March 2002 When Python claims that batteries are included, they mean that Python has a very rich standard library. Today I had a vivid demonstration. I was sick of seeing ads in my Yahoo mail, so I did the hosts file hack: enter the ad servers' names as 127.0.0.1, and the images can't be served. It worked: instead of ad images, I had broken images. They're not pretty, but at least they aren't ads. Then I figured, "if I had a simple web server running on this machine, I could serve my own gif in place of those ads, and I wouldn't have broken images". I did a little poking around in the Python manuals, and 8 lines later, I was done: import BaseHTTPServer, SimpleHTTPServer This is a web server which returns a one-pixel green gif no matter what file was requested. I run this on my machine, and now I have nice clean pages with no ads and no broken images, and a pleasing green field where the ads used to be!
tagged:
python» react | |
Comments
Add a comment: