dse-assignment/components/orchestration/orchestration_server.py
Marco Zeisler 480eff011f move ident request to orchestration_server.py;
import sys modules for proper pickling;
2021-06-02 21:51:16 +02:00

40 lines
900 B
Python

import threading
import requests
from flask import Flask
from orchestrator import Orchestrator
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World'
@app.route('/api1')
def api1():
return 'api1'
@app.route('/api2')
def api2():
return 'api2'
if __name__ == '__main__':
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
try:
response = requests.get(ENTITY_IDENT_URL + 'cars')
cars = response.json()
response = requests.get(ENTITY_IDENT_URL + 'traffic_lights')
traffic_lights = response.json()
except requests.exceptions.ConnectionError as e:
print("Is the entity_ident_server running and reachable?")
raise e
orc = Orchestrator(cars, traffic_lights)
threading.Thread(target=orc.setup_msg_queues).start()
threading.Thread(target=app.run, args=('0.0.0.0', 5003)).start()