coding python by web?

Gerhard Häring gh_pythonlist at gmx.de
Mon Jun 17 18:06:22 CEST 2002


* Thinkit <aoeu at go.com> [2002-06-17 04:17 -0700]:
> Is there any way to test out simple python code with only a web
> browser (no input or files, just printing text)?  I'm guessing a
> simple cgi setup could do this, but has it been implemented anywhere?

Hi, "Thinkit",

dunno if it's implemented, yet, but it's not difficult to do. Below I've
put a quick, working draft, replace exec with print to see the code.

The trick is to redirect sys.stdout and use exec.

Things not implemented in the draft:
- using a restricted environment
- handling exceptions gracefully, displaying a traceback

import zlib,base64
exec(zlib.decompress(base64.decodestring("""
eNpdUstq3TAQ3esrplMu2HBjh0IpBNubQKCrLLItFNnWdURkSUjjJCbk3zvy49atVvM4OjNnZr5+
KacYSuM6acpW29LP9Oys0KN3gaAb9BniHHf/iYK2w89HIUiGQRHUgCWDbtLXVnYvvXOh8DMK8Uyj
SWnEKplN1bp+bgRsr7q4MMLKUuMpW6084gFC6p3DSoKVo6oxdkF7QgjuLdb47Rahc4atH98R3oL0
Nb7qQJM02JyyFZzHqtxZGvjLrK2fCGj2iXZqR03YVOUSPdQvU49H/z8JPqhrJTcRf071UrQqF80s
XohFaJ1GWTxoZfonckEOKsvF+pNzCVKw/FdpJpXtQs88vFwIF/TwO1LPFRjKyyhWR7TT5aICx/at
FLuRuK84BqxIIcZ5MK6VJnLs45PdZe+bJ9S76mDrSVu4gs+wA8W/tIfOtmaKqNRLdstde+6EAO+d
JWXpJo36DtIqlsn8srhDljs5wQeuF4B321Gw+uNkOb6V4FX2WX5Nc2I1WIH4A+u46F4=
""")))

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 29.2 °C      Wind: 3.3 m/s





More information about the Python-list mailing list