开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜