Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'configure': 0.04; 'subject:help': 0.07; 'cc:addr:python-list': 0.09; 'scripts': 0.09; 'part,': 0.09; 'php,': 0.09; 'url:github': 0.09; 'python': 0.10; 'apache': 0.14; 'subject:python': 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:mail- ig0-x22a.google.com': 0.16; 'simplicity,': 0.16; 'subject:run': 0.16; 'wrote:': 0.16; 'config': 0.18; 'example.': 0.18; 'frameworks': 0.18; 'project,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'function,': 0.22; 'sep': 0.22; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'required.': 0.26; 'message-id:@mail.gmail.com': 0.27; 'looks': 0.29; 'routing,': 0.29; 'code': 0.30; 'compared': 0.30; 'run': 0.33; 'file': 0.34; 'server': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'framework': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'seem': 0.37; 'stuff': 0.38; 'test': 0.39; 'does': 0.39; 'where': 0.40; 'subject:with': 0.40; 'some': 0.40; 'per': 0.62; 'future,': 0.70; '11:07': 0.84; 'chrisa': 0.84; 'simple:': 0.84; 'skip:/ 30': 0.84; 'to:none': 0.91; 'offline.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=u6G2P71yhJSZ1IUvVzsVObd5jfA8zEOqvqcD9Oovfc4=; b=G4CD70QIExIwPN0TsGUijwkJGWnCT0SEaZq253GAlAYjePqCK11aQ65wio/GRYE3Bw 8SdYqcmNAUhXd+g0dWxHB+ZcQJ2KeIcPaHbEV2j3Vk2j2V2DhH5RDSMW8xbf7kchXbgU bX29Gl7+xoj8pTlGlvWYwhHu14Ca2+3ar8khSTffuj8aPDxq+FjTEvOUfGOwSPFpAtXr vSMnhJr0DfhZ/HU8w+/GGgHDnlHbWoLFEzX2sYZdBP0o6qiwhUIkXChdU4+CyOCk7s8T e2nPHZed3hiv/ZGcj//UG99tmcEGqXdv3GR70ZFmNfc08kkQ1KHMV1cC9QQ1j7sNWUH+ o4ng== MIME-Version: 1.0 X-Received: by 10.50.3.66 with SMTP id a2mr22892802iga.92.1441545794609; Sun, 06 Sep 2015 06:23:14 -0700 (PDT) In-Reply-To: <361cf277-b469-4873-891d-0153498794ef@googlegroups.com> References: <3877a9ae-edbd-4d36-925a-5cb3789bd1bd@googlegroups.com> <31ec836b-4cb0-4079-8c12-f6b66a5cd143@googlegroups.com> <361cf277-b469-4873-891d-0153498794ef@googlegroups.com> Date: Sun, 6 Sep 2015 23:23:14 +1000 Subject: Re: Can anyone help me run python scripts with http.server? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441545797 news.xs4all.nl 23838 [2001:888:2000:d::a6]:37658 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96068 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. ChrisA