Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'configure': 0.04; 'subject:help': 0.07; 'scripts': 0.09; 'part,': 0.09; 'php,': 0.09; 'url:github': 0.09; 'python': 0.10; 'times,': 0.13; 'apache': 0.14; 'subject:python': 0.14; '>on': 0.16; '>that': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'simplicity,': 0.16; 'simpson': 0.16; 'subject:run': 0.16; 'wrote:': 0.16; 'config': 0.18; 'example.': 0.18; 'frameworks': 0.18; '2015': 0.20; 'function,': 0.22; 'sep': 0.22; 'cheers,': 0.22; 'this:': 0.23; 'second': 0.24; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'required.': 0.26; 'looks': 0.29; 'routing,': 0.29; "i'm": 0.30; 'that.': 0.30; 'code': 0.30; 'compared': 0.30; 'another': 0.32; 'run': 0.33; 'file': 0.34; 'server': 0.34; 'skip:> 10': 0.35; 'something': 0.35; 'but': 0.36; 'framework': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'charset:us-ascii': 0.37; 'seem': 0.37; 'front': 0.38; 'stuff': 0.38; 'test': 0.39; 'does': 0.39; 'enough': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'subject:with': 0.40; 'some': 0.40; 'back': 0.62; 'per': 0.62; 'cameron': 0.66; 'apart': 0.70; 'future,': 0.70; 'received:61': 0.72; '11:07': 0.84; 'intending': 0.84; 'simple:': 0.84; 'skip:/ 30': 0.84; "there'll": 0.84; 'offline.': 0.91 X-Authentication-Info: Submitted using ID cskk@bigpond.com X-Authority-Analysis: v=2.0 cv=D6DF24tj c=1 sm=1 a=S+mxgBCAB4VxLk4i+avDNg==:17 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=ff-B7xzCdYMA:10 a=pGLkceISAAAA:8 a=NEAV23lmAAAA:8 a=QrVWhbZvAAAA:8 a=hSFg9K16O8gamw7nYUIA:9 a=CjuIK1q_8ugA:10 a=S+mxgBCAB4VxLk4i+avDNg==:117 Date: Mon, 7 Sep 2015 14:05:25 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: Can anyone help me run python scripts with http.server? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) References: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441600481 news.xs4all.nl 23865 [2001:888:2000:d::a6]:36759 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96093 On 06Sep2015 23:23, Chris Angelico wrote: >On Sun, Sep 6, 2015 at 11:07 PM, wrote: >> I will definitely look into python web frameworks in the future, they seem >> complicated to me compared to php for example. I am looking for the simplest >> way to test my python scripts till I understand better how it works and when >> I can configure my own web server to run the framework because I want develop my >> stuff offline. > >Look into Flask. You can do something really simple: >https://github.com/Rosuav/MinstrelHall > >All the code is in one file for simplicity, though for a larger >project, you can break it up as required. (Compared to PHP, where >you're _forced_ to have exactly one file per entry-point, this is a >nice flexibility.) Then I just have one line in my Apache config file >that looks something like this: > >WSGIScriptAlias / /path/to/scripts/MinstrelHall/mh.wsgi > >and Apache does all the rest. There's some cruft in that code to get >around a few oddities, but for the most part, writing a page is as >simple as writing a function, decorated to manage routing, that >returns render_template("somefile.html"). It's pretty easy. Another nice thing about Flask is that you can run it standalone without Apache. I'm knocking something together right now using Flask, and I'm intending to run it without Apache at all. There'll be an haproxy in front of it for other reasons, but to get off the ground you don't even need that. Cheers, Cameron Simpson If you take something apart and put it back together again enough times, you will eventually have enough parts left over to build a second one. - Ayse Sercan