Created
July 9, 2020 06:17
-
-
Save HarshCasper/919bd7e0039274c55c2982819e5580b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/givetext/<sub>/<int:count>') | |
def text_count_meme(sub,count): | |
if count >= 50: | |
return jsonify({ | |
'status_code': 400, | |
'message': 'Please ensure the count is less than 50' | |
}) | |
requested = get_text(sub, 100) | |
random.shuffle(requested) | |
textmeme = [] | |
for post in requested: | |
if len(textmeme) != count: | |
t = { | |
'Title': post["Title"], | |
'Selftext': post["text"], | |
'Upvotes': post["Upvotes"], | |
'Downvotes': post["Downvotes"], | |
'Redditurl': post["Redditurl"], | |
'Subreddit': post["Subreddit"] | |
} | |
textmeme.append(t) | |
return jsonify({ | |
'sub': textmeme, | |
'count': len(textmeme) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment