# How to create a Flask entrypoint to show party

**URL:** <https://discuss.tryton.org/t/how-to-create-a-flask-entrypoint-to-show-party/3876>\
**Category:** Developer\
**Tags:** flask\
**Created:** [March 2, 2021, 6:47am UTC](https://discuss.tryton.org/t/how-to-create-a-flask-entrypoint-to-show-party/3876 "2021-03-02T06:47:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [March 2, 2021, 9:06am UTC](https://discuss.tryton.org/t/how-to-create-a-flask-entrypoint-to-show-party/3876/2 "2021-03-02T09:06:43Z")

</div>

Normally you have the session\_key stored on the flask session object. From ther you can retrive the user by using the `get_user` method.

For example, we use the following decorator to indicate a route requires a user to be logged in:

```python
UserSession = tryton.pool.get('web.user.session')

def login_required(func):                                                      
    @wraps(func)                                                               
    def wrapper(*args, **kwargs):                                              
        session_key = None                                                     
        if 'session_key' in session:                                           
            session_key = session['session_key']                               
        g.user = UserSession.get_user(session_key)                             
        if not g.user:                                                         
            return redirect(url_for('login', next=request.path))               
        return func(*args, **kwargs)                                           
    return wrapper    

```

Then you just need to use this decorator on your `my-account` route. For example:

```python
@app.route('/my-account')                                
@tryton.transaction()                                                          
@login_required     
def account():
     print(g.user.name)

```

Note that I’m using the [flask g object to store data in the application context](https://flask.palletsprojects.com/en/1.1.x/appcontext/#storing-data) that can be read from any function and even from html templates.

The full working example has been posted in [Need some more detailed tutorial on flask tryton - #5 by pilou](https://discuss.tryton.org/t/need-some-more-detailed-tutorial-on-flask-tryton/3601/5)

---

_[View the full topic](https://discuss.tryton.org/t/how-to-create-a-flask-entrypoint-to-show-party/3876)._
