0

I am using Python as backend server & AJAX + HTML for the frontend. when I call my API using postman, it's working fine but giving the CORS issue when I hit from the browser. After adding the flask's CORS library still, I am getting the following error.

  • CORS header 'Access-control-allow-origin' missing.
  • Please find the following method for your reference :
def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument("age")
        parser.add_argument("occupation")
        args = parser.parse_args()
        result = request.get_json()
        name = result['name']       
        password = result['password']

        mycursor = mydb.cursor()

        query = ("select * from Farmer where Farmer_Username = '" + name + "' and Farmer_Password = '" + password + "';")
        print(query)
        mycursor.execute(query)  

        myresult = mycursor.fetchone()
        print(myresult)
        if myresult:
            return "Following user exists - '" + name, 200
        else:
            return "Following user doesn't exists - '" + name, 201           

is there anything I need to add here to resolve the issue? Thanks in advance.

0 Answers0