Answer the question
In order to leave comments, you need to log in
How to show data from backend (Flask) to frontend view (Backbone)?
Hello! There is a set of data on the backend that needs to be shown in a table on the frontend...
Right now Flask does it, but we need to do it with Backbone.
Here is some code:
The route that gives the data:
@app.route('/admin')
def admin_usr():
if 'username' in session:
all_users = Users().get_all_users()
return render_template('admin.html', title='Admin', all_users=all_users)
return redirect(url_for('index'))
</thead>
<tbody>
{% for usr in all_users %}
<tr>
<td>{{usr.l_name}}</td>
<td>{{usr.f_name}}</td>
<td>{{usr.login}}</td>
<td>{{usr.email}}</td>
<td>{{usr.id_role}}</td>
<td>
<div class="small success btn">
<a href='/edit_user?id={{usr.id}}'>Edit</a>
</div>
</td>
Answer the question
In order to leave comments, you need to log in
The point is that your backend would only give index.html once with the entire Backbone application, and then return only JSON, that is, you are already implementing a REST-full API, where your models will communicate via this API.
That is, for example, in order to implement what you have written in flask tempalate,
On the frontend:
On the backend:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question