开发者

calling python script from ajax got: malformed header from script. Bad header

开发者 https://www.devze.com 2023-02-28 11:44 出处:网络
I am writting a application using jquery(ajax) and python. When I send the request using ajax to call a php script, everything works. But when I t开发者_JAVA百科ried to call a python script, I got thi

I am writting a application using jquery(ajax) and python. When I send the request using ajax to call a php script, everything works. But when I t开发者_JAVA百科ried to call a python script, I got this error.

malformed header from script. Bad header=AAAAAA

I am not sure what I am missing. The only difference is the type of script ajax is calling.

Following is my php script called:

*<?php
  echo "AAAAA"
?>*

Following is my python script called:

#!/usr/bin/env python
def main():
    print "AAAAAA"

if __name__ == "__main__":
  main()

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

Thanks


PHP was designed for web programming so it automatically attaches Content-type to HTTP headers but Python doesn't. Prepend this to main():

print "Content-Type: text/html\n"
0

精彩评论

暂无评论...
验证码 换一张
取 消