0
function dragEnd(e) {
      if (activeItem !== null) {
        activeItem.initialX = activeItem.currentX;
        activeItem.initialY = activeItem.currentY;
      }

      var classname = activeItem.className;

      if (classname == "item one") {
        console.log(activeItem.initialX + 20);
        console.log(activeItem.initialY + 20);
        active = false;
        activeItem = null;
      }
      else if(classname == "item two"){
        console.log(activeItem.initialX + 20);
        console.log(activeItem.initialY + 60);
        active = false;
        activeItem = null;
      }
  

How to get the values that console.log elements in Flask. If should I convert JSON element then get, help me how to do that.

1 Answers1

0

I think what you're talking about is sending data from JavaScript to a Flask API, correct me if I am wrong.

For that purpose, you can store your data into a variable and send it through a POST or GET request using axios. Read about axios here.

axios.get("https://flask-app-url.com/endpoint?mydata=SOME_VALUE")

Since you mentioned JSON, I should let you know that it recommended to use the POST method and send JSON.

You then have to receive the data in Flask itself, for which you can create a simple endpoint. For example if you're using the GET method, do something like:

data = request.args.get('mydata')

You get the idea. For POST it would be something like request.form["mydata"] with formdata type.

Neelansh Mathur
  • 516
  • 1
  • 5
  • 10