Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My request is : I have my web pages created in python (wherein there is html code), each pages has a button to go to the next page. Is it possible to get the address of the client when we submit an html form for example ? I mean, to have into the URL address of the client.

If that possible, I'll show my code, else I delete my question.

that's my html code :

ip = cgi.escape(os.environ["REMOTE_ADDR"])

<html>

path install: ${install_path}<br/><br/>

os: ${os}<br/><br/>

unix user: ${user_name}<br/><br/>

<form name="sd" method="get" action="ip/cgi/scriptGet.py">
    Name: <input type="text" name="name"><br/><br/>
    Pseudo: <input type="text" name="pseudo"/><br/><br/>
    <input type="submit" value="OK"/>
</form>

and here my python code:

import os, sys, platform, getpass, tempfile
import webbrowser
import string
import json
import cgi, cgitb, os   

def main( server_IP,install_path):

  template = open('scriptHmtl.phtml').read()

  contenu = string.Template(template).substitute(
            install_path = install_path,
            os = user_os,
            user_name = user_login
            )

if __name__ == "__main__":
  server_IP = sys.argv[1]
  install_path = sys.argv[2]

main(server_IP,install_path)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
140 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can use cgi and REMOTE_ADDR and use like this :

cgi.escape(os.environ["REMOTE_ADDR"])

Put that in a variable and call the variable into action of your html form ....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...