Esempio n. 1
0
def status():
    stats = {}
    for category in data.POSTS:
        stats[category] = {}
        for state in data.STATES:
            stats[category][state] = data.count_posts(category, state)

    os_stats = os.statvfs(__file__)
    stats["disk_free"] = os_stats.f_bavail * os_stats.f_frsize
    stats["disk_total"] = os_stats.f_blocks * os_stats.f_frsize
    stats["load_avg"] = os.getloadavg()

    return jsonify(stats)
Esempio n. 2
0
def posts(name, page=1):
    if name not in data.POSTS:
        abort(404)
    end = page * PAGINATION
    start = end - PAGINATION
    total_pages = (data.count_posts(name, data.STATE_PUBLISHED) //
                   PAGINATION) + 1
    posts = {}
    for post in data.get_posts(name,
                               data.STATE_PUBLISHED,
                               start=start,
                               end=end):
        timestamp = post[data.TIMESTAMP]
        posts[timestamp] = post
    return render_template(
        "posts.html",
        body_id=name,
        posts=posts,
        title=data.POSTS[name],
        name=name,
        page=page,
        total_pages=total_pages,
    )