0

I am trying to get a simple web service running on my local computer. In my cgi-bin directory in the Apache24 folder I added an empty file called pywps.cgi with the following content

#!C:\ProgramData\Anaconda2\envs\wps_env\python.exe
import sys
sys.path.insert(0, r"C:/pywps")
import os
os.environ['PYWPS_CFG']='C:/pywps/pywps.cfg'
os.environ['MPLCONFIGDIR']='C:/ProgramData/Anaconda2/envs/wps_env/Lib/site-packages/matplotlib/mpl-data'
# Note that WPS runs as apache user and not as you, so many more user variables might be needed.
# Restart Apache after adding one.
import pywps

The main index.html file works fine, but when i try to open http://localhost/cgi-bin/pywps.cgi I get an error:

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log

I checked the error log and I've got this going on:

[Wed Sep 19 10:36:25.173859 2018] [core:notice] [pid 11404:tid 476] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Wed Sep 19 10:36:25.191859 2018] [mpm_winnt:notice] [pid 11404:tid 476] AH00418: Parent: Created child process 8080
[Wed Sep 19 10:36:26.134859 2018] [mpm_winnt:notice] [pid 8080:tid 416] AH00354: Child: Starting 64 worker threads.
[Wed Sep 19 10:36:27.134859 2018] [mpm_winnt:notice] [pid 1520:tid 420] AH00364: Child: All worker threads have exited.
[Wed Sep 19 10:37:03.781859 2018] [cgi:error] [pid 8080:tid 976] [client ::1:54670] End of script output before headers: pywps.cgi

I have been looking all over for the end of script output before headers but I'm not sure what could be causing it. I checked and rechecked my DocumentRoot path and also the paths in the cgi file to no avail. Could anyone help please?

EDIT

I tried adding the following after setting the interpreter path:

print("Content-type: text/html\n\n")

Which seems to run the script with no issues but does not output the desired xml. Modifying the above html with xml throws an error:

This page contains the following errors: error on line 2 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error.

Where line 2 contains the additional print statement shown above.

  • Is this the appropriate place to ask questions about Apache? I see from this Meta post that there are perhaps more suitable locations --> meta.stackexchange.com/questions/237189/… – user32882 Sep 19 '18 at 11:10
  • "Is this the appropriate place to ask questions about Apache?" - Your question isn't necessarily about "Apache" as such. It sounds like a general HTTP/web/CGI programming question. When coding a CGI script you need to make sure the necessary HTTP response headers are sent before the response body. It sounds like these have been omitted. Your second error implies the "XML" you are returning is invalid (an XML syntax issue, possibly due to erroneous characters in the output). – MrWhite Sep 19 '18 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.