How to enable CORS in python

前端 未结 2 1999
感动是毒
感动是毒 2021-01-23 06:23

Let me start this with, I do not know python, I\'ve had maybe 1 day going through the python tutorials. The situation is this. I have an angular app that has a python app host

2条回答
  •  执笔经年
    2021-01-23 07:07

    For Python with CGI, I found this to work:

    print '''Access-Control-Allow-Origin: *\r\n''',
    print '''Content-Type: text/html\r\n'''
    

    Don't forget to enable CORS on the other side as well, e.g., JavaScript jQuery:

        $.ajax({ url: URL, 
                 type: "GET", 
                 crossDomain: true, 
                 dataType: "text", etc, etc
    

提交回复
热议问题