0

I understand that there is already a similar query here.

My query is different from the above; I have a function that is already defined in my Python script (a Flask app). I want to be able to call this function in my HTML script WITHOUT going to another webpage/URL (meaning that there is no need to create an @app.route in the Python script).

I want it to be such that when the user clicks on the link, the function is called (it's a visual plotting function), and on the same page/URL the plot is created and displayed.

How can this be done in general? Thank you.

3
  • You can use a AJAX get() or post() Method. Commented Jan 27, 2020 at 9:34
  • you can use JQuery and Ajax as mentioned here code-maven.com/slides/python-programming/flask-and-ajax-jquery Commented Jan 27, 2020 at 9:43
  • I dont think you can do that without modifying your existing route or creating a new one. Even ajax requires a route that you can point to. Commented Jan 27, 2020 at 9:46

1 Answer 1

1

When you want to modify a page after it has been loaded in general you use javascript.

And if you need to query new datas or to process datas on the backend side as it is the case here, you'll use Ajax which allows you to query your backend without reloading your page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.