Friends profile page

2877 views javascript

I am designing a web app that is similar to Facebook. Right now I am stuck on how to load a friends profile page... On the users main page there's a section with all the user's friends. Each friend is displayed with an tag. The link leads to the profile page.

Ideally I would like the profile page do display: 'This is {{friends}}'s Profile page'.

I am having a hard time to to dynamically display the clicked on Friends name...

Here's the some code:

The html for the friend links:

<div class='friends'>
            <b>You are Friends with:</b>
            {% for x in range(friends|length) %}
            <li><a id='{{loop.index}}'
            method='POST'  href="/friends_Profile" name='{{friends[loop.index-1][0] 
            [0]}}_{{friends[loop.index-1][0][1]}}' value="{{number[loop.index -1][0]}}"> 
            {{friends[loop.index -1][0][0]}} {{friends[loop.index -1][0][1]}}</a></li>

            {% endfor %}


Here's the friends Profile html:

{% extends "layout.html" %}

{% block title %}


{% endblock %}

{% block main %}

    <h1>This is {{friend}}'s profile</h1>

{% endblock %}

And here's the python code (nothing really here yet):

@app.route('/friends_Profile', methods=["GET"])
def friends_profile():

    return render_template('friends-profile.html', friend=friend)

So ideally the user would click on the friends name, a new page would load and display the friends information....

answered question

1 Answer


Couple of things:

you are POSTing to /friends_Profile when it only allows GET method=["GET"]

also in the friends_profile function, you haven't specified where the friend variable is coming from in friend=friend (best place might be from flask.request)

posted this

Have an answer?


Please login first before posting an answer.