Python script call from ajax received: invalid header from script. Bad headline

I am writing an application using jquery (ajax) and python. When I send a request using ajax to call the php script, everything works. But when I tried to call the python script, I got this error.

Invalid header from script. Bad title = AAAAAA

I'm not sure what I am missing. The only difference is the type of script called by ajax.

The following is my php script:

*<?php echo "AAAAA" ?>* 

Below is my python script:

 #!/usr/bin/env python def main(): print "AAAAAA" if __name__ == "__main__": main() 

============================================= Any idea?

thanks

+6
source share
1 answer

PHP was designed for web programming, so it automatically attaches Content-type headers to HTTP, but Python does not. Prepare this for main() :

 print "Content-Type: text/html\n" 
+17
source

Source: https://habr.com/ru/post/886408/


All Articles