how to initiate an interactive python script from an html cgi?

42 views
Skip to first unread message

arthur sherman

unread,
Mar 24, 2015, 9:30:10 PM3/24/15
to django...@googlegroups.com
i have a python script which currently runs in a shell cli.
i'd like to initiate this script from a web page.
the closest i got was to have the output displayed on the webpage (w/o linefeeds),
but it crashed when requesting input via raw_input().
i simply did 'exec python-script-name' from the cgi.
ok, i now understand why it crashed and why the output is displayed primitively
it's  now my understanding that django can help.
where's the best place to start?
tnx
ams

Derek

unread,
Mar 25, 2015, 11:58:14 AM3/25/15
to django...@googlegroups.com
You could look at using a tool like Skulpt which allows you to run scripts with interaction in a browser window:


E.g. from their example:

Python 2.6(ish) (skulpt, Wed Mar 25 2015 17:52:34)
[Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/37.0.2062.120 Chrome/37.0.2062.120 Safari/537.36] on Linux i686

f = raw_input()
f
'rest'

Tom Evans

unread,
Mar 25, 2015, 1:39:49 PM3/25/15
to django...@googlegroups.com
The best solution is to rewrite it so that it can be used non-interactively.

Much, much much less reliable is to use an "expect" like library, eg pexpect.

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages