Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100909
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: CGI |
| Date | Mon, 28 Dec 2015 03:13:22 +1100 |
| Lines | 41 |
| Message-ID | <mailman.33.1451233162.11925.python-list@python.org> (permalink) |
| References | <567DA87F.40803@fuckaround.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de cn/df+Gea51sN1C85u7LJQmNCPpL8g83TBYPgMrxEEUQ== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'url:localhost': 0.09; 'python': 0.10; ':-)': 0.12; 'output': 0.13; 'django': 0.13; 'instead.': 0.15; '7:35': 0.16; ':-/': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'module:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subprocess': 0.16; 'url:py': 0.16; 'wrote:': 0.16; 'frameworks': 0.18; 'language': 0.19; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '3.x': 0.22; 'am,': 0.23; '(like': 0.23; 'dec': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'script': 0.25; "i've": 0.25; 'command': 0.26; 'skip:# 10': 0.27; 'message-id:@mail.gmail.com': 0.27; 'cgi': 0.29; 'question:': 0.29; 'print': 0.30; 'help!': 0.30; "i'd": 0.31; 'run': 0.33; 'url:python': 0.33; 'usually': 0.33; 'picking': 0.33; 'utility': 0.33; 'received:google.com': 0.35; 'easiest': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'url:library': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'thanks': 0.37; 'release': 0.37; 'received:209': 0.38; "didn't": 0.39; 'enough': 0.39; 'rather': 0.39; 'some': 0.40; 'url:3': 0.60; 'show': 0.62; 'christmas': 0.66; 'worth': 0.67; '26,': 0.72; 'chrisa': 0.84; "it'd": 0.84; 'merry': 0.84; 'pol': 0.84; 'similar)': 0.84; 'to:none': 0.91; 'migrating': 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=534e6a/x1/UqdoEBJvjl56QSEpsjgnSdzcHkVj/TJME=; b=VOW8USW74pkURbDE+LOgJ0ol4BV+RcDuro1tauoYeXiLUmulEQwnEvfP1H3k63dA+2 BUW+jrLVgULHHOu4QXqu1wBaSZ3nwE4AKJn2/gQQXZVzD7VKCu66DXlbblGvLMT7dinQ aCkkUkYigE1MVfE0j400lyM/Es1cmO/iaI8dlM4NCVFS//CzJEE0vbh1eoC7eASQk5sd WVXApW7TrF+2/1inZZLQVbD2tRwtgA/U5bHuyNlV5498k6AVFabMeDjA5Weo/Ns1zJ2p 268UiM+e2NjqDnBOn/4NVJDyxqeZGJtzedZecjKB6fA9hVDiNwLA8YSarlAJ+gljNDQH zv6g== |
| X-Received | by 10.107.14.73 with SMTP id 70mr18612302ioo.31.1451232802103; Sun, 27 Dec 2015 08:13:22 -0800 (PST) |
| In-Reply-To | <567DA87F.40803@fuckaround.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:100909 |
Show key headers only | View raw
On Sat, Dec 26, 2015 at 7:35 AM, Pol Hallen <pythonml@fuckaround.org> wrote: > Merry Christmas to all :-) > > A (newbie) question: I'd like learn about CGI pyhton script to create some > utility using http://localhost/python_script01.py > > Something like that: > > #!/usr/bin/python > print "Content-type: text/html" > print > print "<html>" > print "<center>Hello!</center>" > print "</html>" > > How can I execute a local command (like ls or similar) and show output via > browser? > > I didn't find enough documentation to work with python and CGI :-/ > > Is python not good language to use it with CGI? > > Thanks for help! :) Hi! I would recommend picking up one of the Python web frameworks like Django or Flask. It's usually easier than using CGI. But either way, the easiest way to run a local command is the subprocess module: https://docs.python.org/2/library/subprocess.html https://docs.python.org/3/library/subprocess.html I've provided two links because, unless you have a really good reason for using Python 2, it'd be well worth using Python 3 instead. There are lots of neat new features in the 3.x line, so it'll be best to start on 3.x rather than migrating later. The current release is 3.5, and new releases keep coming out. :) ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: CGI Chris Angelico <rosuav@gmail.com> - 2015-12-28 03:13 +1100
csiph-web