Wednesday 1 November 2017

python - How can I display environment variable

I code in python, and I have two python
files.
In the first I make
:



import cgi, cgitb,
os
export REMOTE_ADDR

def main(addr,
name):


t =
open('recei.py').read()

having =
string.Template(template).substitute(
name = name,
addr =
cgi.escape(os.environ["REMOTE_ADDR"])

)


in the second python
file I have my HTML code ( I put only a part of the form )
:




            name="sendData" method="get" action="echo
${addr}">


but I
have a big error
:



File "./send.py", line 12, in

main(addr, name)
File "./send.py", line 45, in
main
addr = cgi.escape(os.environ["REMOTE_ADDR"])

File
"/usr/lib/python2.6/UserDict.py", line 22, in __getitem__
raise
KeyError(key)
KeyError:
'REMOTE_ADDR'

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...