I am trying to program a Python script on Apache on a Raspberry Pi. My script contains:
#!/usr/bin/env python3
print("Content-type: text/html\n\n")
print("<!DOCTYPE html>\n<head>")
# ... other code
try:
with picamera.PiCamera() as camera:
camera.capture('camera.jpg')
except Exception as error:
errorMsg = error
The PiCamera code produced an error (because I am migrating some existing code to a new Pi and haven't moved the camera over yet). The error is caught, but Apache still produced a 500 error. The error log shows:
malformed header from script 'start.py': Bad header: * failed to open vchiq instanc
It seems that the PiCamera error output was piped to the Http output. Shouldn't this be fine, as my first print function has already output two blank lines? Does the error message mean that the PiCamera output being interpreted as Http headers? If so why?