Beispiel #1
0
def add_tweets():
    print ("add tweet")
    user_tweet = {}
    if not request.json or not 'username' in request.json or not 'body' in request.json:
        abort(400)
    user_tweet['tweetedby'] = request.json['username']
    user_tweet['body'] = request.json['body']
    user_tweet['created_at']=strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    user_tweet['id'] = random.randint(1,1000)
    return jsonify({'status': Requests.add_tweet(user_tweet)}), 201
Beispiel #2
0
def add_tweets():
    user_tweet = {}
    if not request.json or not 'tweetedby' in request.json or not 'body' in request.json:
        abort(400)

    user_tweet['tweetedby'] = request.json['tweetedby']
    user_tweet['body'] = request.json['body']
    user_tweet['created_at'] = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
    if len(user_tweet) == 0:
        return 405
    return jsonify({'status': Requests.add_tweet(user_tweet)}), 201