I have deployed my python app with flask to heroku.com :
from flask import Flask
from flask_cors import CORS
from flask import Response
from flask import request
import sys
import json
app = Flask(__name__)
CORS(app)
cards = [
{"id": "1", "header": "x", "description": "y" },
{"id": "2", "header": "y": "description": "z" },
{"id": "3", "header": "z": "description": "x" },
{"id": "4", "header": "y", "description": "x" }
]
@app.route('/cards/', methods=['GET'])
def get_cards():
return json.dumps(cards)
@app.route('/cards/', methods=['POST'])
def post_cards():
new_card = json.loads(request.data)
max_id = 0
for card in cards:
if int(card['id']) > max_id:
max_id = int(card['id'])
new_card['id'] = str(max_id + 1)
cards.append(new_card)
return new_card
if __name__=="__main__":
app.run(debug=True)
If I post new card and then try to get all card several times in a row, I always get different data (sometimes I receive initial cards set, sometimes updated cards set). What could be the reason of the problem?