POC POC Web Development & APIs 1 — Questions and Answers
Question 1: Which Python micro-framework is most commonly used to build lightweight web applications and REST APIs?
- Flask (Correct answer)
- Django
- Tornado
- Pyramid
Correct answer: Flask
Flask is a lightweight WSGI micro-framework that provides minimal built-in features, making it easy to start building web apps and APIs.
Question 2: Which HTTP method is typically used to create a new resource in a REST API?
- POST (Correct answer)
- GET
- PUT
- DELETE
Correct answer: POST
The POST method submits data to the server to create a new resource, returning 201 Created on success.
Question 3: What Python library is the standard for making HTTP requests in Python scripts?
- requests (Correct answer)
- urllib2
- httplib
- http_client
Correct answer: requests
The `requests` library is the most popular third-party library for making HTTP requests due to its clean, human-friendly API.
Question 4: What does REST stand for in web API design?
- Representational State Transfer (Correct answer)
- Remote Execution Service Technology
- Resource Entity Service Transfer
- Rapid Endpoint Service Template
Correct answer: Representational State Transfer
REST (Representational State Transfer) is an architectural style for distributed hypermedia systems defined by Roy Fielding.
Question 5: In Flask, which decorator is used to map a URL path to a view function?
- @app.route() (Correct answer)
- @app.url()
- @app.path()
- @app.endpoint()
Correct answer: @app.route()
The `@app.route('/path')` decorator registers a URL rule and associates it with the decorated Python function.
Question 6: What HTTP status code indicates a successful request?
- 200 (Correct answer)
- 404
- 500
- 301
Correct answer: 200
HTTP status code 200 (OK) indicates the request succeeded and the server returned the expected response.
Which Python micro-framework is most commonly used to build lightweight web applications and REST APIs?