Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CGI: Error 500
#1
Hello, I'm new to Apache/LAMPP and CGI.

I tried the example CGI script from here:
https://wiki.python.org/moin/CgiScripts

But in my browser (at http://localhost/cgi-bin/4m.cgi)
I get the error:

Error:
Server error! The server encountered an internal error and was unable to complete your request. Error message: End of script output before headers: 4m.cgi If you think this is a server error, please contact the webmaster. Error 500 localhost Apache/2.4.43 (Unix) OpenSSL/1.1.1g PHP/7.4.5 mod_perl/2.0.8-dev Perl/v5.16.3
When I try a non-existing filename in the cgi-bin directory I get a different error, so I'm sure the general web-server setup is not completely wrong. At least the error proves that it can locate the CGI file.

I use xubuntu 20.04 Linux and the file 4m.cgi is set to the permissions: -rwxrwxr-x and owned by root.

I checked all web dev pages I could find linked from this forum, but I can't solve my problem.

I've read the chapter "Configuration" at https://wiki.python.org/moin/CgiScripts
But I don't know how to do the steps described there.

Do you know any helpful idea?

EDIT: I use Python 3.

Greetings
Peter Wiehe
Reply
#2
(Jun-11-2020, 05:29 AM)PeterLinux Wrote: Hello, I'm new to Apache/LAMPP and CGI.
You are using stuff that's mostly dead(CGI) in Python,or not used so much anymore like Apache/LAMPP.
Python Wrote:cgi is going to be deprecated in Python 3.8 and removed in 3.10

Short history the Python community did know that CGI had a lot problems that was to big to fix.
So as new way to to connect to web was written WSGI(all Python code).

The new way of doing CGI in Python is not to use WSGI directly,but eg Flask which is a thinner layer above WSGI.
Then is close to HTML/CSS with very little overhead,simpler and much powerful than the old CGI way.

The two most popular ones Django and Flask both has WSGI underneath and no CGI.
Both Flask and Django has build in web-server for local development,
this make it easy to start and don't have think about server config.
Only if want to share with world then drop development server,
and use something that more production ready like Gunicorn | uWSGI and Nginx.

Example of setup starting from a blank Ubuntu 20.04 distor,so this can be applied elsewhere even if not use DO.
How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 20.04
Other Python friendly hots eg Heruko | PythonAnywhere | AWS Lambda(no server setup).
Reply
#3
OK, thanks. So Flask is the way to go. :)

I mark this question as solved.

Greetings
Peter
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020