diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c2fd858..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3.8-alpine - -LABEL org.opencontainers.image.source=https://github.com/RalphTro/epcis-event-hash-generator -LABEL org.opencontainers.image.description="This container hosts web services for generating event hash. Basically supports `GET /health` and `POST /hash` http endpoints." - -RUN apk --no-cache --update add bash inotify-tools curl - -WORKDIR /usr/src/app - -COPY requirements.txt ./ -RUN pip install -r requirements.txt - -EXPOSE 5000/tcp - -COPY . /usr/src/app/ -ENTRYPOINT ["python3", "/usr/src/app/webapi/api.py"] diff --git a/README.md b/README.md index 91ee0f3..5394161 100644 --- a/README.md +++ b/README.md @@ -36,15 +36,6 @@ For usage information run python3 -m epcis_event_hash_generator -h ``` - -### Web Service - -The script also comes wrapped as a web service in a docker image for ease of integration into a testing environment. -You may use - -- [the latest release version of the web service container](https://github.com/RalphTro/epcis-event-hash-generator/packages/484860 ). See here for usage. - - ## Introduction There are situations in which organisations require to uniquely refer to a specific EPCIS event. For instance, companies may only want to store the hash value of a given EPCIS event on a distributed shared ledger ('blockchain') instead of any actual payload. Digitally signed and in conjunction with a unique timestamp, this is a powerful and effective way to prove the integrity of the underlying event data. Another use case consists to use such an approach to populate the eventID field with values that are intrinsic to the EPCIS event - if an organisation captures an event without an eventID field (which is not required as of the standard) and sends that event to a business partner who needs to assign a unique ID, they can agree that the business partner populates the `eventID` field applying this methodology before storing the event on the server. If the organisation later wants to query for that specific event, it knows how the eventID was created, thus is able to query for it through the eventID value. EPCIS events have a couple of differences to other electronic documents: diff --git a/webapi/api.py b/webapi/api.py deleted file mode 100644 index 0e7599a..0000000 --- a/webapi/api.py +++ /dev/null @@ -1,38 +0,0 @@ -import os -import sys -from flask import Flask, abort, request - -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) - - -app = Flask(__name__) -app.config["DEBUG"] = True - - -@app.route('/', methods=['GET']) -def home(): - return "

Welcome to event hash generator

Use POST /hash endpoint to generate hash of your event

" - - -@app.route('/health', methods=['GET']) -def health(): - return "IMOK" - - -@app.route('/hash', methods=['POST']) -def hash(): - - from epcis_event_hash_generator import hash_generator, json_to_py, xml_to_py - - if request.content_type == 'application/json' or request.content_type == 'application/ld+json': - events = json_to_py.event_list_from_epcis_document_str(request.data.decode("utf-8")) - elif request.content_type == 'application/xml': - events = xml_to_py.event_list_from_epcis_document_str(request.data.decode("utf-8")) - else: - return abort(404, "Invalid content_type in request") - - hashes = hash_generator.epcis_hashes_from_events(events) - return ",".join(hashes) - - -app.run(host='0.0.0.0')