Commit d663bd9e authored by Cédric Bonhomme's avatar Cédric Bonhomme

Returns all EPCIS events involving the electronic product code (EPC) given in parameter.

parent 0b518654
......@@ -5,6 +5,7 @@ import random
import datetime
from flask import jsonify, request
import models
from refuge import app
......@@ -14,6 +15,26 @@ def index():
"""
return jsonify({})
@app.route('/what/<string:epc>', methods=['GET'])
def what(epc=None):
"""
Returns all EPCIS events involving the electronic product code (EPC)
given in parameter.
"""
result = models.EPCISEvent.objects()
epcis_events = [epcis_event.data for epcis_event in result if \
epc in epcis_event.data["ObjectEvent"]["epcList"].values()]
if len(epcis_events) == 0:
return jsonify(result="no epcis event")
return jsonify(result="ok", epcis_events=epcis_events)
@app.route('/where/<string:epc>', methods=['GET'])
def where(epc=None):
"""
"""
pass
@app.errorhandler(404)
def not_found(error=None):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment