Correct Answer : HTTPException
Explanation : HTTPException is used to return HTTP replies with problems to the client.
@app.get(‘/users’) def get_users(): pass
@app.post(‘/users’) def create_user(user: dict): pass
@app.middleware() def my_middleware(request, response): pass
@app.exception_handler(ValueError) def handle_value_error(request, exc): pass
Correct Answer : @app.middleware() def my_middleware(request, response): pass
Explaination : Is a valid FastAPI middleware, which intercepts requests and responses in the application and can modify them or perform additional operations.
Correct Answer : All of the above
Explanation : Following are the advantages of dependency injection :* Reuse shared functionality* Share database connections* Authentication and security requirements
Correct Answer : Dependency injection
Explanation : Dependency injection is the process through which an item obtains other objects on which it depends.