Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44004
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'encoding': 0.05; 'explicitly': 0.05; 'ugly': 0.07; '2to3': 0.09; 'encode': 0.09; 'function,': 0.09; 'http': 0.09; 'url:github': 0.09; 'python': 0.11; 'wrote': 0.14; 'clauses': 0.16; 'cleaner': 0.16; 'expecting': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handler.': 0.16; 'nearest': 0.16; 'porting': 0.16; 'subject:3.3': 0.16; 'write,': 0.16; 'translated': 0.19; 'seems': 0.21; 'code,': 0.22; 'bytes': 0.24; 'helper': 0.24; 'fairly': 0.24; '(or': 0.24; 'question': 0.24; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'that.': 0.31; '3.2': 0.31; 'way?': 0.31; 'run': 0.32; 'quite': 0.32; 'at:': 0.34; 'could': 0.34; "can't": 0.35; 'advice': 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'too': 0.37; 'project': 0.37; 'step': 0.37; 'to:addr:python-list': 0.38; 'that,': 0.38; 'structure': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'up,': 0.60; 'most': 0.60; 'new': 0.61; 'simple': 0.61; 'first': 0.61; 'making': 0.63; 'more': 0.64; 'direct': 0.67; 'naughty': 0.84; 'str.': 0.91; 'mistakes': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=d8iH1W7oDgEv5bOE6UhlAV60K7M18TvtmHXw78hhJ3A=; b=ZV3yusw1v2J70m7IjYz7lEOzpFhoj4G0ELZODU/yEA4OD/uN6z2ykD8TqaAVRsfgdI Xg9rb9ZubmC3foHMDxqSNboBiT/3y9D9tN7VVHzqqyt0OgtfY1mwOYC/RquwzabO+XZ6 vK6InV9Uh164qgGz6B3KpkCc++m9vYbJKFVZo+o67uZ3NFOu1Jc6I8Ptrs89WDuQYxh0 SatYvvN+IBCISOzQmcbE2yqMqAwC87P3nOcZpEkMto1kdLSdCOVYQ0k2OWusnQgUKrtt Vf5aQT5bJFVuO/GHFdEFqE4zlh/fBOWi9WTkGq3z8StM1vwVmS0C7xruvuDy1WNsUDTP NsAA== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.91.230 with SMTP id ch6mr4221443vdb.42.1366551987789; Sun, 21 Apr 2013 06:46:27 -0700 (PDT) |
| Date | Sun, 21 Apr 2013 23:46:27 +1000 |
| Subject | Porting 2.x to 3.3: BaseHTTPServer |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.879.1366551990.3114.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366551990 news.xs4all.nl 2286 [2001:888:2000:d::a6]:34891 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44004 |
Show key headers only | View raw
I'm porting an old project to Python 3, with the intention of making one codebase that will still run on 2.6/2.7 as well as 3.2+ (or 3.3+, if 3.2 is in any way annoying). My first step was to run the code through 2to3, and the basics are already sorted out by that. Got one question though, and it's more of an advice one. In the current version of the code, I use BaseHTTPServer as the main structure of the request handler. 2to3 translated this into http.server, which seems to be the nearest direct translation. But is that the best way to go about making a simple HTTP server? Also, it's expecting bytes everywhere, and I can't find a simple way to declare an encoding and let self.wfile.write() accept str. Do I have to explicitly encode everything that I write, or is there a cleaner way? (I could always make my own helper function, but would prefer something standard if there's a way.) The current version of the code is at: https://github.com/Rosuav/Yosemite It's ugly in quite a few places; when I wrote most of that, I was fairly new to Python, so I made a lot of naughty mistakes (bare except clauses all over the place, ugh!). Adding support for Python 3 seems like a good excuse to clean all that up, too :) ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Porting 2.x to 3.3: BaseHTTPServer Chris Angelico <rosuav@gmail.com> - 2013-04-21 23:46 +1000
Re: Porting 2.x to 3.3: BaseHTTPServer Roy Smith <roy@panix.com> - 2013-04-21 10:01 -0400
Re: Porting 2.x to 3.3: BaseHTTPServer Chris Angelico <rosuav@gmail.com> - 2013-04-22 00:13 +1000
csiph-web