Skip to content

Instantly share code, notes, and snippets.

@HarshCasper
Created July 9, 2020 05:48
Show Gist options
  • Save HarshCasper/dde166207f90e056d2941513d13a701e to your computer and use it in GitHub Desktop.
Save HarshCasper/dde166207f90e056d2941513d13a701e to your computer and use it in GitHub Desktop.
@app.route('/givememe/<sub>')
def custom_meme(sub):
try:
r = get_meme(sub,100)
except:
return jsonify({
'Status_code': 404,
'Message': 'Invalid Subreddit'
})
requsted = random.choice(r)
while not check_image(requsted["Url"]):
count=count+1
requsted = random.choice(r)
if count == 100:
break
return jsonify({
'Title':requsted["Title"],
'Url': requsted["Url"],
'Upvotes': requsted["Upvotes"],
'Downvotes': requsted["Downvotes"],
'Redditurl': requsted["Redditurl"],
'Subreddit': requsted["Subreddit"]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment