INNER CODE UNIT · Python
getOrder
Azure-Samples/container-apps-store-api-microservice · python-service/app.py:15
def getOrder():
app.logger.info('order service called')
with DaprClient() as d:
d.wait(5)
try:
id = request.args.get('id')
if id:
# Get the order status from Cosmos DB via Dapr
state = d.get_state(store_name='orders', key=id)
if state.data:
resp = jsonify(json.loads(state.data))
else:
resp = jsonify('no order with that id found')
resp.status_code = 200
return resp
else:
resp = jsonify('Order "id" not found in query string')
resp.status_code = 500