Python Beem Project: Fugly Friends List Temporary Home Part 2

in #hive-103590last month

My fugly follower/following list found a temporary home here.
https://socialist-whistler-74621.herokuapp.com/

I haven't added follow/unfollow thing yet, but I just deployed to hero for now.
demo.gif

I think list looks ok but overall... still kind of look weird to me.
But I will work on the design later.

Anybody know a super simple way to deploy web app somewhere for free? 😂
I kind of want to pipeline and automate the whole development and deploy thing... but I don't know exactly how that works so I just don't want to spend money for something before I play around with it.

This is my beem project repo here.
https://github.com/tomoyan/beem_project
Main app code is only this much

from beem import Hive
from beem.nodelist import NodeList
from beem.account import Account

from flask import Flask, render_template, redirect
from forms import UserNameForm
from markupsafe import escape
from config import Config
import logging

app = Flask(__name__)
app.config.from_object(Config)

# logging.warning("APP STARTED")


@app.errorhandler(404)
def not_found(e):
    form = UserNameForm()
    return render_template('index.html', form=form)


@app.route('/', methods=('GET', 'POST'))
def index():
    form = UserNameForm()
    if form.validate_on_submit():
        username = form.username.data.lower()

        # return redirect(url_for('friends'))
        return redirect('/friends/' + username)

    return render_template('index.html', form=form)


@app.route('/friends')
@app.route('/friends/<username>')
@app.route('/friends/<username>/')
def friends(username=None):
    data = {}
    if username:
        username = escape(username).lower()
        data['followers'] = get_friends_data(username, 'followers')
        data['following'] = get_friends_data(username, 'following')

    return render_template('friends.html', data=data)


def get_friends_data(username, follow_type):
    # Setup node list
    nodelist = NodeList()
    nodelist.update_nodes()
    nodes = nodelist.get_hive_nodes()
    hive = Hive(node=nodes)
    hive.set_default_nodes(nodes)
    # logging.warning(hive.config.items())

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

    followers = account.get_followers()
    following = account.get_following()

    if follow_type == 'followers':
        return make_dict(followers, following)
    else:
        return make_dict(following, followers)


def make_dict(data_list, find_list):
    my_dict = {}

    for data in data_list:
        if data in find_list:
            my_dict[data] = 1
        else:
            my_dict[data] = 0
    return my_dict

Still a working progress... everything is super messy and I need to clean up
My goal is to be able to organize the friends list so I still have a lot more to go but it's been fun playing with beem and deploy tools and stuff.


Get Rewarded For Browsing! Are you Brave?


Posted with Esteem
t.png

Sort:  

Yay!
Your post has been boosted with ESTM. Keep up the good work!
Dear reader, Install Android: https://android.esteem.app, iOS: https://ios.esteem.app mobile app or desktop app for Windows, Mac, Linux: https://desktop.esteem.app
Learn more: https://esteem.app
Join our discord: https://discord.me/esteem