Add meme count endpoint
This commit is contained in:
parent
f903f4e10c
commit
65cde7fcc9
@ -1,6 +1,7 @@
|
||||
from flask_restx import Api
|
||||
from .search import api as searchNamespace
|
||||
from .get import api as getNamespace
|
||||
from .util import api as utilNamespace
|
||||
|
||||
api = Api(
|
||||
title='Memes',
|
||||
@ -10,3 +11,4 @@ api = Api(
|
||||
|
||||
api.add_namespace(searchNamespace)
|
||||
api.add_namespace(getNamespace)
|
||||
api.add_namespace(utilNamespace)
|
||||
|
22
src/api/util.py
Normal file
22
src/api/util.py
Normal file
@ -0,0 +1,22 @@
|
||||
from flask_restx import Namespace, Resource, fields
|
||||
from flask_restx import reqparse
|
||||
from api.clientGetter import getClientSafely
|
||||
import logging
|
||||
|
||||
# Exported namespace
|
||||
api = Namespace('util', description='Misc Utilities')
|
||||
|
||||
@api.route('/count')
|
||||
@api.doc(description="Get number of memes in store")
|
||||
class getCount(Resource):
|
||||
def get(self):
|
||||
client = getClientSafely()
|
||||
if client is None:
|
||||
return {
|
||||
"message": "Error connecting to S3"
|
||||
}, 500
|
||||
|
||||
return {
|
||||
"count" : len(client.getCurrentMemeList())
|
||||
}, 200
|
||||
|
Loading…
Reference in New Issue
Block a user