Backend Flashcards
(15 cards)
What is an endpoint?
In the context of APIs.
A location where an API receives requests for resources on its server - typically URLs.
What is a path parameter?
Variable components of a URL path which are typically used to identify a specific resource.
Which library (+ associated method) allows you to access query parameters given by a user?
request.args
from the flask
library.
What does the enabling the optional debug mode
do when running an API using Flask?
It enables monitoring for changes in the code and automatically reloads the server when changes are detected.
You are making an endpoint which takes GET requests - why may you use the .route
decorator instead of .get
?
So that single endpoint can handle multiple HTTP methods if you choose to add functionality later.
Features of RESTful APIs: Describe client-server separation.
The client and server operate independently. The client is responsible for making requests, the server processes them and sends back responses.
Features of RESTful APIs: Describe statelessness.
Each request from the client contains all the necessary information - no client-specific data is maintained on the server.
What is cacheability - a feature of RESTful APIs?
The support for caching, the process of storing copies of frequently accessed data to reduce reponse times.
Features of RESTful APIs: Describe uniform interface.
The server for a RESTful API should transfer information in a standard format, so it can be interacted with in the same way regardless of device or type of application.
Features of RESTful APIs: Describe layered system.
Components only engage with layers they directly need to; clients can connect to authorized intermediaries between itself and the server.
Why is building things in a consistent way - like using the principles of REST - important?
It provides a framework for the structure and maintenance of software programs so they are easier to understand, scale and update.
What does ‘mocking’ mean in a testing context?
Creating fake objects that mimic the behaviour of real objects to remove impurities - so units of code can be tested without managing external dependencies.
Why do we use api.test_client()
when testing API programs?
It simulates the responses of the real API, allowing a developer to isolate unit tests from external dependencies.
Also helps save money when using a paid API service.
What is web scraping?
An automated process for extracting data from web pages.
Which Python library do you use for web scraping?
BeautifulSoup
There are other libraries like Selenium, Scrapy, Playwright too.