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 3630714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:18:19+00:00 2026-05-19T00:18:19+00:00

#!/usr/bin/env python # -*- coding: UTF-8 -*- # enable debugging import cgitb cgitb.enable() print

  • 0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

My goal is to replace PHP with Python. I’m pretty good with PHP and I can use Python on my own local machine, but I can’t get it to work on my web server. My web host says they support Python, so I must be doing something wrong.

Now, Python is associated with CGI. Do python files have to go into my cgi-bin folder? I’ve never seen a web file with a py extension or a cgi extension, I don’t know how these things work, I’m really only familiar with PHP.

I watched the first hour of Google’s “Learn Python” class and that only talks about running Python locally.

🙁 Sorry I’m so nub, please fix me.

  • 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-19T00:18:20+00:00Added an answer on May 19, 2026 at 12:18 am

    That’s a perfectly acceptable CGI script. If you are using Apache, it will need to go into your cgi-bin, need to be executable (I may be wrong on this), and you should name it with the common extension for the language .py, or with .cgi.

    If you can control what files your webserver will consider CGI, you can place the file wherever you want. Chances are, you can’t control that. You can view more information on CGI in Apache here: http://httpd.apache.org/docs/2.2/howto/cgi.html

    The basic gist is that Apache will not treat a file as a CGI file unless two conditions are met: The cgi-script will need to be activated using the AddHandler or SetHandler directives, and ExecCGI will need to be enabled in the Options directive. Typically, this is not available to the user in a shared hosting environment.

    EDIT: To clarify, CGI is just a mechanism for you to write scripts in any arbitrary language, and have your webserver execute them and send the output from that script to your clients. It’s not a recommended approach for anything but a simple script, due to the fact that on every single request the server will fire up a new instance of your interpreter. For Python, the best solution would be a WSGI compatible framework, such as Flask, Bottle, or Django. The first two are micro-frameworks that try to stay out of your way, while Django is a full-stack framework that provides a whole lot of glue.

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

Sidebar

Related Questions

The following test fails: #!/usr/bin/env python def f(*args): >>> t = 1, -1 >>>
The system I am using has gnuplot installed in /usr/bin . I don't have
ho-fe3fdd00-12:~ Sam$ easy_install BeautifulSoup Traceback (most recent call last): File /usr/bin/easy_install, line 8, in
Consider the following code and its output: Code #!/usr/bin/perl -w use strict; use Data::Dumper;
Cron installation is vixie-cron /etc/cron.daily/rmspam.cron #!/bin/bash /usr/bin/rm /home/user/Maildir/.SPAM/cur/*; I Have this simple bash script
By default, when you sudo gem install thegemname it will install executables into /usr/bin/
I am converting a linux script from http://www.perlmonks.org/index.pl?node_id=217166 specifically this: #!/usr/bin/perl -w use strict;
Here is a command on free bsd sudo pw usermod ksbuild -s /usr/local/bin/bash how
I am executing a diff command in perl . my @lines = `/usr/local/bin/diff -udr
extension=ext.so zend_extension=/usr/lib/php4/ext.so zend_extension_ts=/usr/lib/php4/ext.so What are the differences?

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.