INNER CODE UNIT · Python

not_found

miztiik/AWS-Demos · How-To/setup-api-gw/app.py:47

def not_found(error):
    return make_response(jsonify({'error': 'Commodity Not found'}), 404)


class CommodityInfo(Resource):
    def get(self, commName):
        commodity = [item for item in msp if item['CommodityName'] == commName]
        if not commodity:
            not_found(404)
        return jsonify(commodity)

api.add_resource(CommodityInfo,'/api/v1.0/CommodityInfo/<commName>', methods=['GET'])

# flask run --host=0.0.0.0
if __name__ == '__main__':
     app.run()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…