E
exscape
Hey everyone,
I'm writing a tiny web server, mostly to learn - security and such is
a non-issue, but learning how to make things secure is of course nice
too. To be clear - I will most likely not even use it myself.
In any case. I've added some minor scripting support, so that you can
write dynamic pages in Python. To do this, I use execfile(), and pass
the script a dictionary with some basic variables. The script then
sets a "ret" variable that's sent back to the browser. That's some
major ugliness right there! If I do a "print" inside the script, then
it'll end up on the server console. I want it to end up in the web
browser.
How would I accomplish this, i.e. redirect the standard output to
somewhere else, such as a variable in the calling script? If it's not
easy (as in, quite trivial) just say so. I've been thinking about
popen(2,3,4) but that's almost as ugly, if not even worse, than the
current "solution".
Thanks in advance.
I'm writing a tiny web server, mostly to learn - security and such is
a non-issue, but learning how to make things secure is of course nice
too. To be clear - I will most likely not even use it myself.
In any case. I've added some minor scripting support, so that you can
write dynamic pages in Python. To do this, I use execfile(), and pass
the script a dictionary with some basic variables. The script then
sets a "ret" variable that's sent back to the browser. That's some
major ugliness right there! If I do a "print" inside the script, then
it'll end up on the server console. I want it to end up in the web
browser.
How would I accomplish this, i.e. redirect the standard output to
somewhere else, such as a variable in the calling script? If it's not
easy (as in, quite trivial) just say so. I've been thinking about
popen(2,3,4) but that's almost as ugly, if not even worse, than the
current "solution".
Thanks in advance.