This is my update endpoint for the Delete Route for a particular URL in Flask:
# Delete Route for a particular trip
@app.route('/trips/<int:trip_id>', methods=['DELETE'])
def delete_trip(trip_id):
trip = trips.get(trip_id) #the trip refers to particualar trip to delete..actually to be queried from the database
del trips[trip] # logic to delete a trip
return jsonify({'message': 'Trip deleted successfully!'})
However the error I get in the console when running testing the Delete API endpoint in Postman is:
File “E:WlinkLocation_Trabackendmain.py”, line 654, in delete_trip
del trips[trip] # logic to delete a trip
KeyError: None
1