def login(): ''' Render home page ''' if request.method == 'POST': name = request.get_json()['name'] return get_user(name) return render_template('login.html')
def to_do(name): ''' Route to get the tasks and post a task :param name: of the user ''' user = get_user(name) if request.method == 'POST': return save_task(user, dict(request.get_json())) if request.method == 'GET': return render_template('to_do.html', user=user)
def user_info_get(): email = session['email'] if email is None: return returns(1, {}, '未登录或登陆过期') one = get_user(email) user_info = { "username": one.username, "email": one.email, "imageUrl": one.imageUrl, "birthday": one.birthday } return returns(0, user_info, '成功!')
def task(name, task_id): ''' Route to update or delete a task :param name: of the user :param task_id: of the task ''' user = get_user(name) if request.method == 'DELETE': return delete_task(user, task_id) if request.method == 'PATCH': return check_task(user, task_id)
def resolve_get_user(*_, id): return get_user(id)
def resolve_user(post_obj, info): user_id = post_obj['user_id'] return get_user(user_id)
def get_user_details(): '''Get user details''' username = request.args.get("username") details = get_user(username) return json.dumps(details)
def get_user_details(): '''Retrieves user details''' username = request.args.get("username") user = get_user(username) return json.dumps(user)