-2

I am building a web-app on top of hadoop(its for internal use) using python's flask framework using jinja2 templates. I have a requirement where I need to communicate/do some changes on existing html. I am not sure how to do that.

The only way I know is to use:

render_template('xyz.html',some_vale=some_value)

But this will render the template again.

Following are the task that I need to achieve:

  1. The requirement would be to pop up a bootstrap toast when I get an acknowledgement that the data is inserted into hive successfully. I do not want to use flash module in flask.

  2. One more requirement is to show/hide loading dialog while I fetch the data from database. Once the search request is initiated, till the data is fetched, the dialog should be visible and then it should disappear.

How can talk to HTML from python like we do in java script using id.

Appreciate the help.

satish silveri
  • 358
  • 3
  • 17
  • You can hide your result into your template(html file). Later you can use same result for your condition base requirement using javascript. – yogesh10 Aug 29 '19 at 10:32

1 Answers1

1

Sounds like you need to create a separate endpoint for API-like request, fire AJAX request from displayed page, and do appropriate actions on success/failure.

How can talk to HTML from python like we do in java script using id.

No. Flask generates web pages from templates and data you pass to it. You need to undertand a difference between what is done on server side and what is done on client side.

Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95