Skip to Content
Cloud Native Python
book

Cloud Native Python

by Manish Sethi
July 2017
Intermediate to advanced
374 pages
8h
English
Packt Publishing
Content preview from Cloud Native Python

GET api/v2/tweets/[user_id]

This function gets the tweets from a specific user.

In order to get tweets from a specific user from the tweets collection, we need to modify our current list_tweet(user_id) function as follows:

    def list_tweet(user_id): 
     db = connection.cloud_native.tweets 
     api_list=[] 
     tweet = db.find({'id':user_id}) 
     for i in tweet: 
       api_list.append(str(i)) 
    if api_list == []: 
       abort(404) 
    return jsonify({'tweet': api_list}) 

Let's test out our API and validate whether it is working as expected or not:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python for DevOps

Python for DevOps

Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu
Cloud Native

Cloud Native

Boris Scholl, Trent Swanson, Peter Jausovec

Publisher Resources

ISBN: 9781787129313Supplemental Content