
Reading financial data from the internet is sometimes challenging. In this short article with two python snippets, I will show how to read it from Wikipedia and from and from API, delivering in JSON format: Reading the data from the…
Data wrangling with Excel and Pandas is actually quite useful tool in the belt of any Excel professional, financial professional, data analyst or a developer. Really, everyonecan benefit from the well defined libraries that ease people’s lifes. These are the…
The Rule of 114 is a quick way to estimate how long it will take to triple your money with compound interest. The idea is simple: divide 114 by the annual interest rate (in %), and you will get an…
The field of geometry offers tools that have withstood the test of time, empowering us to understand and solve a variety of triangular problems. Among these, the Pythagorean Theorem and the Law of Cosines are cornerstone concepts. This article provides…
There is something interesting about linear regression. I have just noticed, that I have actually quite some articles on it some years ago, but today I wanted to make a YouTube video as well. Well, what is the difference this…
So, what exactly is standard deviation? In simple terms, it’s a measure of how spread out the numbers in a dataset are from the mean or average. If the numbers are close to the mean, the standard deviation is small.…
Object oriented programming (OOP) in general is a huge topic, but I have decided to make a 30 minute video, based on the book Math for Programmers, as I liked the way it was explained there: Generally, in the video,…
Working with Python and Excel is actually quite handy, especially if you are into it. In this article, you can see how to create Excel files, write data and formulas into them and read these. Pretty much simple CRUD methods.…
In the previous article, the post and get API methods were presented. In this one, Put and Delete are coming. 🙂 Well, nothing that fancy, this is how these two methods look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# Update item by id @app.route('/api/items/<int:item_id>', methods=['PUT']) def update_item(item_id): data = request.get_json() updated_data = data.get('item') # Get the nested 'item' data if not updated_data: return jsonify({'error': 'No data provided'}), 400 item = next((item for item in items if item['id'] == item_id), None) if item is None: return jsonify({'error': f'Item #{item_id} not found!'}) # Update fields in the item (dummy db) for key, value in updated_data.items(): if key in item: item[key] = value return jsonify({'message': 'Item updated successfully', 'item':item}), 200 # Delete item by id @app.route('/api/items/<int:item_id>', methods=['DELETE']) def delete_item(item_id): item_to_delete = next((item for item in items if item['id'] == item_id), None) if item_to_delete is None: return jsonify({'error': f'Item {item_id} not found!'}), 404 items.remove(item_to_delete) return jsonify({'message': f'Item: {item_to_delete} has been deleted successfully!'}), 200 |
And, of course tests are a…