Hi there! I'm Labby.
That's an excellent and very practical question! Now that your Flask application is running, testing its REST API endpoints is the next logical step.
There are several common ways to test REST API endpoints:
Using
curl(Command Line):curlis a command-line tool for making requests to web servers. It's built into virtually all Linux environments (like your LabEx VM) and is great for quick tests.- How to use it: You use
curlby typingcurlfollowed by the URL of the endpoint you want to test. - Example for your lab: To test an endpoint returning all books, you might use
curl http://127.0.0.1:8080/books. (Note: we haven't defined the/booksendpoint yet, so this specific command won't work until later steps). - Why it's useful: It's fast, doesn't require a GUI, and is good for automated scripts.
- How to use it: You use
Using a Browser: You can often test
GETrequests (for retrieving data) directly by typing the API endpoint URL into your web browser's address bar. The browser will display the response from the API.- Example for your lab: If you had an endpoint
http://127.0.0.1:8080/hello, typing that into your browser would show you the response. - Why it's useful: Easiest for simple
GETrequests; no extra tools needed.
- Example for your lab: If you had an endpoint
API Testing Tools (like Postman or Insomnia): These are standalone applications that provide a graphical user interface (GUI) for making various types of HTTP requests (GET, POST, PUT, DELETE, etc.), setting headers, and sending request bodies easily.
- Why it's useful: Very powerful for complex requests, managing collections of tests, and visualizing responses. You would typically install these on your local computer, not directly in the LabEx VM.
Python
requestsLibrary: If you want to test your API programmatically from another Python script, therequestslibrary is the de facto standard for making HTTP requests in Python.- Example:
import requests response = requests.get("http://127.0.0.1:8080/some_endpoint") print(response.json()) # If the API returns JSON - Why it's useful: Great for writing automated integration tests for your API.
- Example:
Right now, your Flask app is running, and the output 172.60.0.2 - - [17/Dec/2025 10:21:49] "GET / HTTP/1.1" 404 - indicates that someone (likely the system's verify script) tried to access the root path (/) but got a 404 Not Found error. This is expected because you haven't defined any routes (endpoints) in app.py yet!
In upcoming steps, you will be adding routes to app.py and then you can use curl (or your browser for GET requests) to test them.
Did that clarify how you can test the endpoints? Let me know if you would like me to elaborate on any of these methods!