import json

@main.route('/check_selected', methods=['GET', 'POST'])
def check_selected():
    global selected
post = request.args.get('post', 0, type=int)
return json.dumps({'selected post': str(post)})
Passing data from javascript into Flask