def create():
    cache['foo'] = 0
return jsonify(cache['foo'])

@app.route('/increment')
def increment():
    cache['foo'] = cache['foo'] + 1
return jsonify(cache['foo'])

@app.route('/read')
def read():
    return jsonify(cache['foo'])
if __name__ == '__main__':
    app.run()
Preserving global state in a flask application