From 84eb5e49f4318341cd71694e5a27485ef1065641 Mon Sep 17 00:00:00 2001 From: RaiBnod Date: Wed, 27 Nov 2024 14:40:38 +0545 Subject: [PATCH] Adding debugging points --- run.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 41a96b2..a295a95 100644 --- a/run.py +++ b/run.py @@ -11,13 +11,16 @@ app = Flask(__name__) # config uart pins +print("Configuring UART Pins") config_uart_pin() +print("UART Pins configured successfully") # BBB GPIO Lib import Adafruit_BBIO.GPIO as GPIO import Adafruit_BBIO.PWM as PWM import Adafruit_BBIO.ADC as ADC +print("Setting up PINS") # DOs GPIO.setup("P8_7", GPIO.OUT) GPIO.setup("P8_8", GPIO.OUT) @@ -49,9 +52,11 @@ # AIs ADC.setup() +print("PINS setup is successfully completed") + # API stuff api_ver = '1.1' # change version number as needed -api_port = 5000 # API PORT NUMBER +api_port = 5000 # API PORT NUMBER uo = 'uo' ui = 'ui' do = 'do' @@ -67,6 +72,12 @@ def not_found(error): return make_response(jsonify({'error': 'try again :('}), http_error) +@app.errorhandler(Exception) +def handle_exception(e): + logging.exception("Unhandled exception occurred") + return jsonify({'error': str(e)}), 500 + + # index page @app.route('/', methods=['GET']) def index_page(io_num=None, val=None): @@ -178,7 +189,7 @@ def read_ai_all(): if __name__ == '__main__': - app.run(host='0.0.0.0', port = api_port, debug=True) + app.run(host='0.0.0.0', port=api_port, debug=True) # # # READ ALL DOs