INNER CODE UNIT · Python
post_question
kingname/SourceCodeofMongoRedis · chapter_10/QASystem/main.py:44
def post_question():
question = request.json
is_valid = check_question_valid(question)
if not is_valid['success']:
return json.dumps(is_valid, ensure_ascii=False)
title = question['title']
detail = question['detail']
author = question['author']
now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
mongo.insert_question(title, detail, author, now)
return json.dumps({'success': True})
@app.route('/vote', methods=['POST'])
def vote():
vote_data = request.json
print(vote_data)
is_valid = check_vote(vote_data)