Python Beem Project: Account Information Part 5 by tomoyan

View this thread on steempeak.com
· @tomoyan ·
$9.29
Python Beem Project: Account Information Part 5
I have updated my project a bit.
It is kind of nice to know how **HIVE** and **STEEM** are doing so I took some chart widgets from CoinGecko and added to my home page.
Also I have added a "Profile" thing that you can check your account information.
Reputation, voting power, wallet info and delegations.

## https://floating-meadow-28045.herokuapp.com
![ezgif.com-gif-maker.gif](https://images.ecency.com/DQmPYP8ZpjaAiVcMFYTgPEic6HUzVn2ye7ZRJJ5o53Kqcnt/ezgif.com-gif-maker.gif)

UI, layout stuff will probably change again soon since I am going to add information in this page, but it is a nice start.
Design inspirations came from https://hivestats.io/ and https://steemworld.org/ that I use time to time but I don't use all the features. 
I just want some specific information and display it in my way but I like hivestats' clean design so I think it will probably end up looking like to hivestat 🤣 
Hopefully able to add some nice touch to it though 🙈 🙊 🙉 

Main stuff I added was like this 👇 
```
@app.route('/hive/profile', methods=['GET', 'POST'])
def hive_profile():
    form = UserNameForm(request.form)

    if request.method == 'POST':
        if form.validate():
            username = request.form['username'].lower()

            return redirect('/hive/profile/' + username)
        else:
            flash('Username is Required')

    return render_template('hive/profile.html', form=form)


@app.route('/hive/profile/<username>')
@app.route('/hive/profile/<username>/')
def hive_profile_data(username=None):
    data = {}
    if username:
        username = escape(username).lower()
        data = get_user_profile('hive', username)

    logging.warning('get_user_profile')
    logging.warning(data)
    if data:
        return render_template('hive/profile_data.html',
                               username=username, data=data)
    else:
        return render_template('hive/profile_data.html',
                               username=None, data=data)
                               
def get_user_profile(chain_type, username):
    chain = None
    if chain_type == 'hive':
        chain = set_node_list(chain_type='hive')
        chain.is_hive
    elif chain_type == 'steemit':
        chain = set_node_list(chain_type='steemit')
    else:
        return None

    # Create account object
    try:
        account = Account(username)
    except Exception as e:
        logging.warning(e)
        return None

    profile = account.profile

    profile['balances'] = account.get_balances()
    profile['voting_power'] = f"{account.get_voting_power(): .2f}"
    profile['reputation'] = f"{account.get_reputation(): .1f}"

    token_power = account.get_token_power()
    profile['token_power'] = f"{token_power:.3f}"
    logging.warning('token_power')
    logging.warning(token_power)

    # Get delegations
    delegations = account.get_vesting_delegations()
    if delegations:
        profile['delegations'] = get_user_delegations(
            chain, username, delegations)
    else:
        profile['delegations'] = []

    return profile
    
def get_user_delegations(chain, username, delegations):
    # Convert vest to power
    delegation_list = []
    for d in delegations:
        amount = d['vesting_shares']['amount']
        precision = d['vesting_shares']['precision']
        precision = 10 ** precision
        delegatee = d['delegatee']
        vest_amount = float(int(amount) / precision)
        if chain.is_hive:
            delegation_power = f"{chain.vests_to_hp(vest_amount):.3f}"
        elif chain.is_steem:
            delegation_power = f"{chain.vests_to_sp(vest_amount):.3f}"

        delegation_list.append(
            {'delegatee': delegatee, 'amount': delegation_power})

    return delegation_list
```
My stuff is all in here if you like to look at it. 
(please dont. it is a big mess right now lol)
https://github.com/tomoyan/blockchain-tools
<center>
    [Get Rewarded For Browsing! Are you Brave?](https://brave.com/tom490)
    [<img src="https://img.esteem.app/be00j8.png">](https://brave.com/tom490)
    [![happy tears](https://images.ecency.com/DQmUfaVp5UQvASdTyyLrNiBdGB7NxQfxE2wBpNivcDUkCfe/h.gif)](https://tomoyan.github.io/)
    ➡️ [Website](tomoyan.github.io)
    ➡️ [Twitter ](twitter.com/tomoyanTweet)
</center>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
post_id86,891,458
authortomoyan
permlinkpython-beem-project-account-information-part-5
categorypython
json_metadata{"tags":["python","beem","hive","steem","codeonsteem","mini","marlians","dblog"],"image":["https:\/\/images.ecency.com\/DQmPYP8ZpjaAiVcMFYTgPEic6HUzVn2ye7ZRJJ5o53Kqcnt\/ezgif.com-gif-maker.gif","https:\/\/img.esteem.app\/be00j8.png","https:\/\/images.ecency.com\/DQmUfaVp5UQvASdTyyLrNiBdGB7NxQfxE2wBpNivcDUkCfe\/h.gif"],"links":["https:\/\/floating-meadow-28045.herokuapp.com","https:\/\/hivestats.io\/","https:\/\/steemworld.org\/","https:\/\/github.com\/tomoyan\/blockchain-tools","https:\/\/brave.com\/tom490","https:\/\/tomoyan.github.io\/","tomoyan.github.io","twitter.com\/tomoyanTweet"],"app":"steemit\/0.2","format":"markdown"}
created2020-07-30 13:51:42
last_update2020-07-30 13:51:42
depth0
children0
net_rshares15,941,398,728,621
last_payout2020-08-06 13:51:42
cashout_time1969-12-31 23:59:59
total_payout_value4.720 SBD
curator_payout_value4.566 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length4,273
author_reputation870,963,589,956,079
root_title"Python Beem Project: Account Information Part 5"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (34)