Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'exercise': 0.04; 'third- party': 0.04; 'binary': 0.07; '22,': 0.09; '2to3': 0.09; 'http': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'things,': 0.09; 'url:github': 0.09; 'suggest': 0.14; 'frameworks.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'handler.': 0.16; 'nearest': 0.16; 'roy': 0.16; 'simple.': 0.16; 'simplest': 0.16; 'subject:3.3': 0.16; 'ui,': 0.16; 'wrote:': 0.18; 'basically': 0.19; 'translated': 0.19; 'seems': 0.21; 'code,': 0.22; 'handles': 0.22; 'frameworks': 0.24; 'lets': 0.24; 'mon,': 0.24; "haven't": 0.24; 'looks': 0.24; '(or': 0.24; 'sort': 0.25; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; '(this': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; '3.x': 0.31; 'question:': 0.31; 'received:209.85.220.174': 0.31; 'level.': 0.33; 'maybe': 0.34; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'really': 0.36; 'possible': 0.36; 'should': 0.36; 'application': 0.37; 'too': 0.37; 'received:209': 0.37; 'sometimes': 0.38; 'actions': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'structure': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'most': 0.60; 'full': 0.61; 'browser': 0.61; 'simple': 0.61; 'back': 0.62; 'save': 0.62; 'making': 0.63; 'become': 0.64; 'talking': 0.65; 'direct': 0.67; 'feeling': 0.68; 'nobody': 0.68; 'smith': 0.68; 'article': 0.77; 'low': 0.83; 'gut': 0.84; 'hour,': 0.84; 'partial': 0.84; 'url:master': 0.84; 'cutting': 0.91; 'choice.': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=dEZohlXd297KI2IMad8vAYPIHMySFjhzmH67PPYFNm4=; b=p+jwGRAOnE1n/HkHN0PEwrh0tuJhhF79Rg7olshHtDj93Yx3PoVL50sCez8wqdCcXW bgm8230hpTINBZRqWz2ccW0vwOH6JG3NB5KUxvwvA35OSCDr9knt9T5ZMkhZ2U+O7fEE EJf9a3T0prCidEngH1kaahYNOA/tDn/vzRxBGgmlvJSSELoTfHLxbUBn6ljpAIh/IhGY W20JCplnN1WcFSqKISzI8hoNVQ/KWgBA2awg+8X2mChJBy7nJjL3K66jSh3ZE+RaQLAF rlWQkIumLZKVpmuRTBQDVT/1FTlKYcaWd+zPQSZeloR04hVxYU2DynSpk9BgduvLFawJ o2Lg== MIME-Version: 1.0 X-Received: by 10.52.91.230 with SMTP id ch6mr4265584vdb.42.1366553628969; Sun, 21 Apr 2013 07:13:48 -0700 (PDT) In-Reply-To: References: Date: Mon, 22 Apr 2013 00:13:48 +1000 Subject: Re: Porting 2.x to 3.3: BaseHTTPServer From: Chris Angelico 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366553632 news.xs4all.nl 2212 [2001:888:2000:d::a6]:43425 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44006 On Mon, Apr 22, 2013 at 12:01 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> 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? > > For most purposes, I would suggest one of the third-party web > frameworks. For simple things, I'm partial to Tornado, but it's not the > only choice. The advantage of these frameworks is they give you a lot > of boilerplate code that handles all the low-level protocol gunk and > lets you concentrate on writing your application logic. > > My gut feeling is that nobody should ever be using BaseHTTPServer for > anything other than as a learning exercise (or as a base on which to > build other frameworks). It's just too low level. I haven't used the > 3.x http.server, but http.server looks like much of the same. Have a look at the code in question: https://github.com/Rosuav/Yosemite/blob/master/Yosemite.py#L81 It's REALLY simple. I don't need any sort of framework; it's basically just using a web browser as its UI, to save on writing a client. So I'm looking for the simplest possible option; I don't need security or anything (this is designed for a trusted LAN), nor scaleability (we're talking queries per hour, not per second). I'm actually looking at cutting it back even further. There are os.system() calls that I'm thinking should possibly become popen(), and maybe copy a binary into /tmp and giving a full path to it, as sometimes this is used on a low-end system and needs to perform actions with low latency. ChrisA