Best practice for integrating UI and dynamic user-specific content using a Flask app

I am building a website that uses a recommendation system. Users submit a form which is sent to the backend for the recommendation logic calculation; the recommendation response is sent back to the server and the recommendations are shown to the user. Control flow: User submits a form on website. Using PHP, this query is sent to my Flask App. The Flask App processes the query and sends a response back to the server. [Help needed] display results to the user. I have steps 1-3 done, but I am struggling with 4. Since the recommendations differ per user, I am not sure about which approach to take since there seems to a few alternatives. For example, these two options came to my mind – and I’m sure there’s more: The Flask app could return HTML to the server which could be directly displayed on the website. The Flask app could trigger a function on the server side that would generate the HTML displayed on the website. The recommendations will have the same structure, each having some basic structured information (name, contact details, etc.) and a logo picture. Both options have their advantages and disadvantages regarding criteria such as, ease of implementation, speed, and security. However, as a novice in the field, I would like to know what do the professionals suggest. Hence my question is: how should I integrate the backend and the UI; and how do professional websites tackle this issue of dynamically creating content based on user parameters; is there a clear “go-to” approach? Just for completeness, I’m using Wordpress and Elementor for hosting and for the UI; PHP on the server side, and a Python Flask app on the backend. Also, to reiterate, I am able to successfully communicate between my webpage, the server, and the Flask app.

Feb 28, 2025 - 18:25
 0
Best practice for integrating UI and dynamic user-specific content using a Flask app

I am building a website that uses a recommendation system. Users submit a form which is sent to the backend for the recommendation logic calculation; the recommendation response is sent back to the server and the recommendations are shown to the user.

Control flow:

  1. User submits a form on website.
  2. Using PHP, this query is sent to my Flask App.
  3. The Flask App processes the query and sends a response back to the server.
  4. [Help needed] display results to the user.

I have steps 1-3 done, but I am struggling with 4. Since the recommendations differ per user, I am not sure about which approach to take since there seems to a few alternatives. For example, these two options came to my mind – and I’m sure there’s more:

  • The Flask app could return HTML to the server which could be directly displayed on the website.

  • The Flask app could trigger a function on the server side that would generate the HTML displayed on the website.

The recommendations will have the same structure, each having some basic structured information (name, contact details, etc.) and a logo picture.

Both options have their advantages and disadvantages regarding criteria such as, ease of implementation, speed, and security. However, as a novice in the field, I would like to know what do the professionals suggest.

Hence my question is: how should I integrate the backend and the UI; and how do professional websites tackle this issue of dynamically creating content based on user parameters; is there a clear “go-to” approach?

Just for completeness, I’m using Wordpress and Elementor for hosting and for the UI; PHP on the server side, and a Python Flask app on the backend. Also, to reiterate, I am able to successfully communicate between my webpage, the server, and the Flask app.