An open API service indexing awesome lists of open source software.

https://github.com/lab11/fitbit_leaderboard

Compete to be the Fibit step champion!
https://github.com/lab11/fitbit_leaderboard

Last synced: about 1 year ago
JSON representation

Compete to be the Fibit step champion!

Awesome Lists containing this project

README

          

Fitbit Leaderboard
==================

Web application to display a graph of users' weekly steps based on fitbit.com.

Dependencies
------------

The Fitbit Leaderboard runs on Python 3 and requires a few extra packages
to be installed.

sudo pip3 install flask fitbit

Running a Test Instance
-----------------------

The first thing you must configure are the options to the fitbit leaderboard.
Copy `reference_config.py` to `fl_config.py` and update the entries.

Once you have done that, there are a couple ways to test the fitbit leaderboard:

### Test, Fake Data

The fitbit leaderboard can be run with fake data to test the operation. To
create a test database with fake data run:

./create_test_db.py

Then the actual leaderboard webserver can be run with:

./fitbit_leaderboard.py --no-update

Browse to http://127.0.0.1:5000 to view the site.

### Test, Real Data

To use the fitbit leaderboard properly you need to register with fitbit.com
to get API keys. Then `fl_config.py` with the correct API values.

Then simply:

./fitbit_leaderboard.py

### Real Webserver, Real Data

Register with fitbit.com and update `fl_config.py`. Then use nginx and uwsgi.

Run With nginx and uWsgi
------------------------

nginx needs to be recompiled with the `more_set_input_headers` extension
to use the following config script. This lets the python code know what
prefix to use (for example '/fitbit') in the URLs in the HTML. The actual
/fitbit is not included in the python paths so that the code is agnostic
and could be used with any prefix (like '/fb') without changing any code.

### Example nginx conf file:

server {
listen 80; ## listen for ipv4; this line is default and implied

server_name ;

location /static {
alias //static;
}

location /fitbit {
more_set_input_headers 'X-Script-Name: /fitbit';

# Checks if the 'Host' header is set, and if not applies it.
if ($http_host = '') {
more_set_input_headers 'Host: ';
}

include uwsgi_params;
uwsgi_pass unix:/tmp/fitbit_leaderboard.sock;

# This strips the /fitbit prefix from the url
uwsgi_param SCRIPT_NAME /fitbit;
uwsgi_modifier1 30;
}
}

This conf file allows you to put the application with a prefix (this example
uses `/fitbit`) without changing any of the python or html code in the
leaderboard app itself. Using the `more_set_input_headers` directive does
require http://wiki.nginx.org/HttpHeadersMoreModule to be compiled in with
nginx, however.

### uWsgi conf:

[uwsgi]
plugins=python
vhost=true
gid=www-data
uid=www-data
master=true
processes=5
chdir=//fitbit_leaderboard
home=//fitbit_leaderboard/venv
socket=/tmp/fitbit_leaderboard.sock
callable=app
module=fitbit_leaderboard
chmod-socket=666
enable-threads=true