To run locally, you must have MongoDB running on defaults. The default db name is speedtests If not, go ahead and set an environment variable, MONGOHQ_URL.
mongodb://user:pass@localhost:10047/dbname
You should then create a user with an apiKey. You'll use this as a part of your store URL for speedtests.py.
$ mongo
> use speedtests
> db.users.insert({apiKey: "MYSECRETAPIKEY"})
Install requirements and run.
$ pip install Flask Flask-PyMongo
$ python server.py
* Running on http://0.0.0.0:5000/
Depends and based of speedtest-cli
Install requirements.
$ pip install speedtest-cli
Set STORE_URL environment variable and run.
$ STORE_URL="http://0.0.0.0:5000/api/store/MYSECRETAPIKEY" python speedtest.py
Example result output.
{
"latency": 18.358,
"server_id": "3807",
"download_speed": 3.303375400144142,
"city": "Bayamon",
"url": "http://speedtest01.hotspotpr.net/speedtest/upload.php",
"country": "Puerto Rico",
"created_at": 1391690356,
"distance": 0.0,
"longitude": -66.15,
"upload_speed": 0.39577672547006476,
"user": {
"_id": {
"$oid": "52f381bed986b064a3934318"
},
"apiKey": "abc1234"
},
"country_code": "PR",
"latitude": 6.978635648337157,
"_id": {
"$oid": "52f382cc32cc6c35284f7fa9"
},
"sponsor": "HOTSPOTPR BROADBAND INTERNET"
}
The setup I used on my RaspberryPI running Raspbian.
$ sudo apt-get update
$ sudo apt-get install python-pip
$ sudo pip install pip --upgrade
$ sudo pip install speedtest-cli
$ curl -O https://gist.github.com/jpadilla/8843461/raw/speedtest.py
$ (crontab -l 2>/dev/null; echo "* */3 * * * STORE_URL="http://speedtests.herokuapp.com/api/results/MYSECRETAPIKEY" python /home/pi/speedtest.py >/dev/null 2>&1") | crontab -