[prog] Re: [Techtalk] How to write web proxy in Python?
Nancy Ging
turtle at camano.net
Thu Jan 9 14:53:57 EST 2003
I have a question--what is the difference, in terms of how and when you
would use each--between python and perl? I've done lots of perl programming
but never taken a look at python. Is there a good reason to do so?
Thanks,
Nancy Ging
Turtle Island Web Design
http://www.turtlehome.com/
An island of vision in a sea of technological possibilities...
-----Original Message-----
From: programming-admin at linuxchix.org
[mailto:programming-admin at linuxchix.org]On Behalf Of Amanda Babcock
Sent: Thursday, January 09, 2003 1:47 PM
To: programming at linuxchix.org
Subject: Re: [prog] Re: [Techtalk] How to write web proxy in Python?
On Fri, Jan 10, 2003 at 08:16:18AM +1100, Mary wrote:
> LinuxChix has a programming list, so I've Cc-ed them.
Oh, I never thought of sending to programming :) Oops.
> I would suggest using something higher level than sockets if you
> possibly can, unless the assignment requires sockets.
It's not an assignment. My university's online instruction system is
awful and is confusing Opera :( I'm trying to work around that.
> Python has a
> socket module which is easier to use than the C one - it is slightly
> higher level and handles some of the errors itself, so I'd recommend it
> over C, since you've never programmed sockets before.
I actually found the Python socket tutorial, and it looks like pie.
(http://www.amk.ca/python/howto/sockets/)
> If the assignment doesn't require sockets, Python has an httplib module
> that might be appropriate, which will open connections for you without
> you needing to open and use sockets yourself.
>
> You might even be able to use the urllib module instead, which will
> fetch a url for you with a single line of code.
My goal is for the proxy to be completely transparent except for fixing
the bad Javascript the university is sending me. It actually seems to
me that using just the sockets would be easier since I can effectively
just let my browser and the university talk to each other, stepping in
only to fix ^M to ^J. If I just plug sockets into each other, I don't
even need to *know* the URL (just the hostname and port :)
> To make the proxy, I would suggest you look at Python's SimpleHTTPServer
> module, or maybe BaseHTTPServer and override some methods,
Hmm. That sounds like more work.
> your replacement (Python's string module will handle the replacement).
Thanks! I hadn't got around to how to do the replacement yet :) Good
to know where to find it.
> For a beginning Python programmer, I'd suggest working through the
> tutorial at http://www.python.org/doc/current/tut/tut.html
Cool!
> All modules I've mentioned are documented at
> http://www.python.org/doc/current/modindex.html
Thanks! I'll let everybody know how it goes.
Amanda
_______________________________________________
Programming mailing list
Programming at linuxchix.org
http://mailman.linuxchix.org/mailman/listinfo/programming
More information about the Programming
mailing list