Issues when calling APIs

What happens if we try to get an item that is not available, such as item 5 (that is http GET 0.0.0.0:3000/my-api/5)? In development mode, a long detailed message is returned. In production mode, setting export FLASK_ENV=production results in a terse and t0-the-point response. The application crashes and Werkzeug, the application manager, reports it.

Fixing the issues in GET

It would be better if, it returned instead of crashing, a “404 NOT FOUND” error. Let’s fix this by updating the get method in the OneNumber class and test it with http GET 0.0.0.0:3000/my-api/5

Get hands-on with 1400+ tech skills courses.