From d26c522e69886dd580a699bdf07c796cf1addfc4 Mon Sep 17 00:00:00 2001 From: Jaap <33700526+GewoonJaap@users.noreply.github.com> Date: Sat, 23 Mar 2024 11:07:59 +0100 Subject: [PATCH] Changes --- psa_car_controller/web/view/api.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/psa_car_controller/web/view/api.py b/psa_car_controller/web/view/api.py index 87a1cf5..45654c7 100644 --- a/psa_car_controller/web/view/api.py +++ b/psa_car_controller/web/view/api.py @@ -186,27 +186,27 @@ def settings_section(section: str): APP.config.write_config() return json_response(config_section.json()) -@app.route('/get_vehicletrips') +@app.route('/vehicles/trips') def get_trips(): try: car = APP.myp.vehicles_list[0] trips_by_vin = Trips.get_trips(Cars([car])) trips = trips_by_vin[car.vin] trips_as_dict = trips.get_trips_as_dict() - return FlaskResponse(json.dumps(trips_as_dict, default=str), mimetype='application/json') + return jsonify(trips_as_dict) except (IndexError, TypeError): logger.debug("Failed to get trips, there is probably not enough data yet:", exc_info=True) - return FlaskResponse(json.dumps([]), mimetype='application/json') + return jsonify([]) -@app.route('/get_vehiclechargings') +@app.route('/vehicles/chargings') def get_chargings(): try: chargings = Charging.get_chargings() - return FlaskResponse (json.dumps(chargings, default=str), mimetype='application/json') + return jsonify(chargings) except (IndexError, TypeError): logger.debug("Failed to get chargings, there is probably not enough data yet:", exc_info=True) - return FlaskResponse(json.dumps([]), mimetype='application/json') + return jsonify([]) @app.route('/settings') def settings():