Skip to content

Commit

Permalink
Return json from digitize
Browse files Browse the repository at this point in the history
  • Loading branch information
laurynas committed Mar 16, 2024
1 parent ef1381c commit a39e930
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

@app.route('/digitize', methods=['POST'])
def digitize():
decimals = request.args.get('decimals', default=0, type=int)
data = request.get_data()
image = Image.open(BytesIO(data))
return digitizer.detect_string(image)
reading = digitizer.detect_string(image)
value = float(reading) / (10 ** decimals)
return json.dumps({'value': value}), 200, {'Content-Type': 'application/json'}

@app.route('/meter/<identifier:meter_id>', methods=['POST'])
def update_meter(meter_id):
Expand Down

0 comments on commit a39e930

Please sign in to comment.