Python CGI programming on Mac OSX

Discussion in 'Python' started by Kaushik Roy, May 21, 2015.

  1. Kaushik Roy

    Kaushik Roy

    Joined:
    May 21, 2015
    Messages:
    2
    Likes Received:
    1
    Hello I am using Mac OSX mavericks and I am new to apache2 and cgi, but have been using python for a while now.

    My python script called hello.py in the cgi-executable folder is:

    #!/anaconda/bin/python
    import cgi, cgitb
    form = cgi.FieldStorage()
    first_name = form.getvalue('first_name')
    last_name = form.getvalue('last_name')
    print"Content-type:text/html\r\n\r\n"
    print"<html>"
    print"<head>"
    print"<title>Hello - Second CGI Program</title>"
    print"</head>"
    print"<body>"
    print"<h2>Hello %s %s</h2>"%(first_name, last_name)
    print"</body>"
    print"</html>"

    my form.html file is:

    <formaction="/cgi-bin/hello.py"method="get">
    First Name: <inputtype="text"name="first_name"><br/>
    Last Name: <inputtype="text"name="last_name"/>
    <inputtype="submit"value="Submit"/>
    </form>

    But the input from the form doesn't go through to the python script!
    but if i execute localhost/cgi-bin/hello.py?first_name=F&last_name=L
    it displays HELLO F L

    please tell me where to place the form.html file so it can find the hello.py cgi script

    I have looked at stack overflow a lot and not found any solution. Please help!

    The hello.py is in the cgi-executables folder
     
    Kaushik Roy, May 21, 2015
    #1
    1. Advertisements

  2. Kaushik Roy

    simpsons

    Joined:
    Sep 26, 2015
    Messages:
    1
    Likes Received:
    0
    hi, Roy,
    I have the same problem with you. Have you solved it yet?

     
    simpsons, Sep 26, 2015
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Mahan
    Replies:
    1
    Views:
    649
    Simon Burton
    Nov 16, 2003
  2. edadk

    Problem with Python on MAC OSX

    edadk, Jun 29, 2004, in forum: Python
    Replies:
    4
    Views:
    754
    Ronald Oussoren
    Jun 30, 2004
  3. Sven Hilmahr
    Replies:
    0
    Views:
    490
    Sven Hilmahr
    Sep 23, 2004
  4. MichaelW
    Replies:
    1
    Views:
    859
    Kevin Walzer
    Nov 23, 2005
  5. Nainto
    Replies:
    7
    Views:
    653
  6. Adrian Petrescu

    Client-side cookies on Python in Mac OSX

    Adrian Petrescu, Jul 13, 2007, in forum: Python
    Replies:
    3
    Views:
    587
    John J. Lee
    Jul 14, 2007
  7. =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?=

    python-mcrypt install on Mac OSX

    =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?=, Sep 20, 2007, in forum: Python
    Replies:
    3
    Views:
    677
    =?UTF-8?Q?Ahmad_=E3=8B=A1_Baitalmal?=
    Sep 20, 2007
  8. Gnarlodious

    mod-python on Mac OSX 10.5

    Gnarlodious, Jan 8, 2008, in forum: Python
    Replies:
    1
    Views:
    420
    Arnaud Delobelle
    Jan 8, 2008
Loading...