0

i am using these two lines in two different functions which basically renders a page and displays data which has been passed. The data which is passed takes time to get created and till then the page keeps loading as it is waiting for the process which creates data to finish. I want it to work in a way where my html pages can be rendered and data can be created by running a process in background and later be used by html page. The data is used to create table or display it using flask template in html.

return render_template("preferences2.html", columns=column_names, data=data.head().values)

return render_template('results.html', Algorithm_used=str(Algorithm_used[algorithm]),
    selected_columns=columns, time_taken=time_taken,
    confusion_matrix=confusion_matrix(y_test,pred),
    labels = labels, cr=classification_report(y_test, pred, output_dict=True),
    accuracy=accuracy_score(y_test, pred), X_test=X_test[:5],
    y_test=y_test.head().values, pred=pred[0:5])

I thought of threading but the problem is that it will render the html page without data and will not display anything after the process is complete. Any help would be appreciated.

2
  • 1/ Use an async task queue (celery or other) - threading doesn't really scale, specially in Python -, and 2/ use ajax polling (or websockets but that's more involved) to get the results and notify the user when they are ready. Apr 28, 2020 at 7:12
  • Question has actually nothing to do with machine-learning - kindly do not spam irrelevant tags (removed).
    – desertnaut
    Apr 28, 2020 at 10:32

0

Your Answer

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