@app.route("/home")
def get_response_data():
number = userinput_from_form
return render_tamplate('home.html', number=number)
@app.route("/home")
def post_response_data():
value = number
function_from_backend = aggregation(value)
platform = aggregation.get_something()
scoring = aggregation.do_something()
return render_template('home.html', platform=platform, scoring=scoring)
My html looks like this using jinja2 templates:
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Score</th>
<th scope="col">Platform</th>
<th scope="col">Info</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">{{ result }}</th>
<td>{{ scoring }}</td>
<td>{{ platform }}</td>
<td>@asdfa</td>
</tr>
<tr>
What I am trying to achieve is get a user input and then populate a table with the values that another function I have built(aggregation), unrelated to flask, and get those values and "post" them in the table. I would Ideally like to not have the user switch pages just show the results directly on the same page.
My problem is I am not sure how to get the input from the user in the frontend and use it on the other function to return my desired result. I have tried using request.data, request.args.get('number') and sessions but I am stuck.