Chapter 14 Assignment
Web Development & Scraping
Basic Questions (10)
- What is Flask and what is it used for?
- How do you create a basic route in Flask?
- What is FastAPI and how is it different from Flask?
- Explain the purpose of the
@app.get()
decorator in FastAPI.
- How do you install the
requests
library?
- What does the
requests.get()
function do?
- What is the role of
BeautifulSoup
in web scraping?
- How do you run a Flask app locally?
- How can you return JSON response in Flask?
- Explain the use of HTML templates in Flask.
Intermediate Questions (10)
- How do you pass URL parameters to Flask routes?
- Explain dependency injection in FastAPI with an example.
- How can you handle POST requests in Flask?
- Describe how to scrape all hyperlinks from a web page using
BeautifulSoup
.
- How do you handle form data submission in Flask?
- Explain how to use Pydantic models in FastAPI for request validation.
- What is the difference between
find()
and find_all()
methods in BeautifulSoup?
- How can you manage CORS (Cross-Origin Resource Sharing) in FastAPI?
- How do you serve static files in a Flask application?
- Write a Flask route that returns a rendered HTML template passing dynamic data.
Advanced Questions (10)
- How do you implement asynchronous endpoints in FastAPI?
- Explain how to secure Flask APIs using JWT tokens.
- Describe scraping JavaScript rendered content and possible solutions.
- How can you deploy a Flask app using a production WSGI server like Gunicorn?
- Explain the use of background tasks in FastAPI.
- How do you handle pagination when scraping multiple web pages?
- Discuss the differences between Flask's synchronous model and FastAPI's asynchronous model.
- Write a FastAPI endpoint that accepts a JSON payload and validates it using Pydantic.
- How do you test Flask routes using the Flask testing client?
- Explain ethical considerations and legal issues related to web scraping.