-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.py
38 lines (30 loc) · 965 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from flask import Flask, jsonify
from memeGenerator import ScrapMemes
# Making a flask app
app = Flask(__name__)
# setting flask jsonify to not sort dictionary keys while returning as API
app.config['JSON_SORT_KEYS'] = False
# Random Meme Generator
@app.route('/')
def meme_api():
result = ScrapMemes()
return jsonify(result)
# Numbered Meme Generator
@app.route('/<int:num>/')
def meme_api_no(num):
result = ScrapMemes(num=num)
return jsonify(result)
# Topic wise Meme Generator
@app.route('/<string:topic>/')
def meme_api_topic(topic):
result = ScrapMemes(topic=topic)
return jsonify(result)
# Topicwise and numbered meme generator
@app.route('/<string:topic>/<int:num>/')
def meme_api_topic_and_no(topic, num):
result = ScrapMemes(topic=topic, num=num)
return jsonify(result)
if __name__ == "__main__":
# running the flask app in threaded mode
# to allow handling more requests at once
app.run(threaded=True)