From 026e4d6f9dd8797b65ee5027fa20ddd6de85d66f Mon Sep 17 00:00:00 2001 From: David Eder Date: Tue, 8 Jun 2021 14:57:31 +0200 Subject: [PATCH] Add crossway api for traffic_lights --- .../src/app/component/landing/landing.component.ts | 5 ++++- components/x_way/x_way_server.py | 14 +++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/control_center/src/app/component/landing/landing.component.ts b/components/control_center/src/app/component/landing/landing.component.ts index 4374f17..e8a24fe 100644 --- a/components/control_center/src/app/component/landing/landing.component.ts +++ b/components/control_center/src/app/component/landing/landing.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AgmMap, AgmMarker} from '@agm/core'; +import {RestService} from "../../services/rest.service"; @Component({ selector: 'app-landing', @@ -8,7 +9,9 @@ import {AgmMap, AgmMarker} from '@agm/core'; }) export class LandingComponent implements OnInit { - constructor() { + constructor( + private restService: RestService + ) { } @ViewChild('map') map: AgmMap; diff --git a/components/x_way/x_way_server.py b/components/x_way/x_way_server.py index b98b89d..b094262 100644 --- a/components/x_way/x_way_server.py +++ b/components/x_way/x_way_server.py @@ -28,10 +28,18 @@ def get_cars(): return json_util.dumps({'cursor': cars}) +@app.route('/api/v1/resources/traffic_lights', methods=['GET']) +def get_traffic_lights(): -@app.route('/api2') -def api2(): - return 'api2' + try: + response = requests.get(ENTITY_IDENT_URL + 'traffic_lights') + traffic_lights = response.json()['cursor'] + + except requests.exceptions.ConnectionError as e: + print("Is the entity_ident_server running and reachable?") + raise e + + return json_util.dumps({'cursor': traffic_lights}) if __name__ == '__main__':