0

I am new in running python with xammp server. I have done all the required setup to run python in xammp server by following this link Running Python scripts with Xampp. While trying to running my code i always 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 postmaster@localhost 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.**

My error log says this: [Tue Jan 19 10:29:34.529875 2021] [cgi:error] [pid 11652:tid 1860] [client ::1:50570] malformed header from script 'python.py': Bad header: Hello World

i am attaching the code for my file too.

#! C:\Users\"UserName"\AppData\Local\Programs\Python\Python39\python.exe
print("Content-Type: text/html\n\n")
import cgi

print("Hello Python")

i have tried everything i could to search for the solution but nothing is helping. Please help me finding a solution. Thank you

smartF
  • 29
  • 7

1 Answers1

0

Update the \n\n to use a carriage return (\r\n\r\n), and add another in.

This should make your HTTP headers valid, as they may not be terminating correctly.

Edit: You can also try multi-line print instructions such as

print "Content-type: text/html"
print ""

This is interpreting the body as the header (never terminated) so terminating this correctly should fix it.

iods
  • 16
  • 1