add caching

Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
This commit is contained in:
2017-08-25 23:27:12 -04:00
parent b3702e7b8f
commit fd0f10e625
3 changed files with 7 additions and 4 deletions
+1
View File
@@ -14,3 +14,4 @@ html5lib = "*"
bs4 = "*"
requests = "*"
simplejson = "*"
flask-cache = "*"
+2
View File
@@ -46,9 +46,11 @@ class MWT(object):
return func
def convert_to_decimal(f):
return Decimal("{0:.8f}".format(f))
class Coin():
"""A Coin, unlike Mario's."""
+4 -4
View File
@@ -4,6 +4,7 @@ from scraper import get_coins, get_coin, Coin
from wallets import wallets
from flask import Flask, jsonify, render_template, request
from flask.ext.cache import Cache
from flask_sslify import SSLify
import maya
@@ -17,11 +18,13 @@ pro_db = records.Database(os.environ['HEROKU_POSTGRESQL_TEAL_URL'])
app = Flask(__name__)
app.debug = True
sslify = SSLify(app)
cache = Cache(app ,config={'CACHE_TYPE': 'simple'})
@app.route('/')
@cache.cached(timeout=60)
def hello():
lbc = get_coin('lbc')
@@ -80,9 +83,6 @@ def get_history(coin):
else:
rows = db.query(q, coin=c.name)
return jsonify(history=[
{
'value': r.value,