Skip to content

Instantly share code, notes, and snippets.

@waltervargas
Created March 9, 2017 19:47
Show Gist options
  • Save waltervargas/ff4cfcf30e20b304b136c8162efb5837 to your computer and use it in GitHub Desktop.
Save waltervargas/ff4cfcf30e20b304b136c8162efb5837 to your computer and use it in GitHub Desktop.
Python version for webui.py used by dockercoins -> https://github.com/jpetazzo/dockercoins
from flask import Flask
from flask import jsonify
from redis import Redis
import time
app = Flask(__name__, static_url_path="")
redis = Redis('redis')
@app.route('/')
def root():
return app.send_static_file('index.html')
@app.route('/json')
def json():
coins = redis.hlen('wallet')
hashes = redis.get('hashes')
now = time.time()
return jsonify(
coins=coins,
hashes=int(hashes),
now=now
)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
@waltervargas
Copy link
Author

@jpetazzo here a python version of the webui.js file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment