flask api 개발

    8. 미니터(Miniter) API 개발 (타임라인)

    8. 미니터(Miniter) API 개발 (타임라인)

    이번에 구현할 기능은 타임라인 기능이다. 타임라인은 팔로우한 사용자의 글 목록을 보여주는 기능이다. 코드는 다음과 같다. @app.route("timeline/", methods=['GET']) def timeline(user_id): if user_id not in app.users: return '사용자가 존재하지 않습니다.', 400 follow_list = app.users[user_id].get('follow', set()) follow_list.add(user_id) timeline = [tweet for tweet in app.tweets if tweet['user_id'] in follow_list] return jsonify({'user_id' : user_id, 'timeline' : ..