How to use flask route only for calling a function and not redirecting in browser


$("#btn").click(function () { // assuming submit button as id btn
    type: "POST", //
    url: "/write_log", // url to the function
    data: {
      // include data here if you want to send something in json format
    success: function (response) {
      $("#update_logger").html(response) // manipulate the dom
      localStorage.setItem("log", response);
if request.method == "POST":
   logger = upload.logger
   return logger