Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:21:46+00:00 2026-05-28T01:21:46+00:00

Recently I started reading Mark Lutz’s Programming Python – Fourth Edition. I am a

  • 0

Recently I started reading Mark Lutz’s “Programming Python – Fourth Edition”. I am a mac user, using ActivePython and OSX 10.6.7. Anyways, everything was going fine until the first instance of CGI in the book. The code example creates a form, and uses a POST method for finding someone’s name:

<html>
<title>Interactive Page</title>
<body>
<form method=POST action="cgi-bin/testing.cgi">
    <p><b>Enter your name:</b>
    <p><input type="text" name="user">
    <p><input type="submit">
</form>
</body>
</html>

The CGI script is then put into a subdirectory, as shown in the HTML and looks like this:

#!/usr/bin/python
import cgi
form = cgi.FieldStorage()
print("Content-type: text/html\n")
print("<title>Reply Page</title>"
if not 'user' in form:
    print("<h1>Who are you?</h1>")
else:
    print("<h1>Hello <i>%s</i>!</h1>" % cgi.escape(form['user'].value))

However when I load the html and run a test, the script does not execute. What occurs is that either the browser loads the entire script as Hypertext, or that I download a .py file; depending on the browser I use (Eclipse and Safari show me text, Chrome and Firefox download a file). If it means anything, when I open the .html file it opens using file:// and not http://.

I’m not sure if this could be a problem with my script, or with a variety of other things.
If anyone has any suggestions on executing python-based CGI on a mac that would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:21:47+00:00Added an answer on May 28, 2026 at 1:21 am

    You need to configure and run a webserver, then access the file through that webserver with a url like http://localhost:8080/cgi/foo.py, and not the local path to the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently started reading OpenGL Superbible 5th edition and noticed the following: Having just
Hi I recently started experimenting with python currently reading Think like a computer scientist:
I have recently started reading Programming Challenges book by S. Skiena and believe or
I just started using Git recently and I was reading up on Git best
I recently started reading about ASP.net MVC and after getting excited about the concept,
I've started with ASP.NET MVC recently, reading blogs, tutorials, trying some routes, etc. Now,
I recently started work on a personal coding project using C++ and KDevelop. Although
I recently started using Eclipse at work for my Java servlet projects. I've been
We recently started using maven for dependency management. Our team uses eclipse as it's
I recently started using scons to build several small cross-platform projects. One of these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.