INNER CODE UNIT · Python

vote

kingname/SourceCodeofMongoRedis · chapter_10/QASystem/main.py:58

def vote():
    vote_data = request.json
    print(vote_data)
    is_valid = check_vote(vote_data)
    if not is_valid['success']:
        return json.dumps(is_valid)
    doc_type = vote_data['doc_type']
    value = vote_data['value']
    doc_id = vote_data['doc_id']
    if doc_type == 'question':
        mongo.vote_for_question(doc_id, value)
    else:
        mongo.vote_for_answer(doc_id, value)
    return json.dumps({'success': True})

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…