Add event store connection
This commit is contained in:
parent
b9c450cedc
commit
5d337d6d25
@ -1,2 +1,3 @@
|
||||
flask
|
||||
Flask-Cors
|
||||
requests
|
||||
@ -2,11 +2,14 @@ import requests
|
||||
from bson import json_util
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
from flask import request
|
||||
import json;
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
||||
EVENT_STORE_URL = 'http://eventstore:5001/api/keys/'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
@ -14,6 +17,21 @@ def hello_world():
|
||||
return 'Hello World'
|
||||
|
||||
|
||||
|
||||
@app.route('/api/v1/resources/car_events', methods=['GET'])
|
||||
def get_cars_events():
|
||||
vin = request.args.get('vin')
|
||||
|
||||
try:
|
||||
response = requests.get(EVENT_STORE_URL + 'DAF:' + vin + '/')
|
||||
cars = json.loads(response.text)
|
||||
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print("Is the EVENT_STORE_URL running and reachable?")
|
||||
raise e
|
||||
|
||||
return json_util.dumps({'cursor': cars})
|
||||
|
||||
@app.route('/api/v1/resources/cars', methods=['GET'])
|
||||
def get_cars():
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user