Fast API MCQs with answers Page - 15

Here, you will find a collection of MCQ questions on Fast API. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

R

Ravina • 3.96K Points
Extraordinary

Q. How can you restrict allowed methods in CORS in FastAPI?

  • (A) allowed_methods in CORSMiddleware
  • (B) cors_methods parameter
  • (C) CORSFilter
  • (D) request.allow(methods=...)

R

Ravina • 3.96K Points
Extraordinary

Q. How can you include metadata for a FastAPI application?

  • (A) In the URL path
  • (B) In request headers
  • (C) In FastAPI constructor (title, description, version)
  • (D) In the environment variables

R

Ravina • 3.96K Points
Extraordinary

Q. Which utility helps you build query parameter constraints in FastAPI?

  • (A) PydanticValidator
  • (B) SchemaBuilder
  • (C) Query()
  • (D) Param()

R

Ravina • 3.96K Points
Extraordinary

Q. What happens if you use `response_model` in a route?

  • (A) It disables input validation
  • (B) It automatically validates and filters the response data
  • (C) It changes the request format
  • (D) It logs the model

R

Ravina • 3.96K Points
Extraordinary

Q. What is the default port when running Uvicorn?

  • (A) 5000
  • (B) 3000
  • (C) 8000
  • (D) 8080

R

Ravina • 3.96K Points
Extraordinary

Q. Which object is required to use background tasks in FastAPI?

  • (A) TaskQueue
  • (B) BackgroundHandler
  • (C) BackgroundTasks
  • (D) AsyncJob

R

Ravina • 3.96K Points
Extraordinary

Q. Which module provides `File` and `Form` imports in FastAPI?

  • (A) fastapi.datastructures
  • (B) fastapi.requests
  • (C) fastapi
  • (D) fastapi.tools

R

Ravina • 3.96K Points
Extraordinary

Q. Which exception class is used to return custom HTTP errors in FastAPI?

  • (A) RequestError
  • (B) FastAPIError
  • (C) HTTPException
  • (D) ValidationException

R

Ravina • 3.96K Points
Extraordinary

Q. What is the purpose of `status` module in FastAPI?

  • (A) To define application status
  • (B) To create API logs
  • (C) To use HTTP status codes as constants
  • (D) To validate database operations

R

Ravina • 3.96K Points
Extraordinary

Q. Which of the following methods is used to define a DELETE endpoint in FastAPI?

  • (A) @app.remove()
  • (B) @app.del()
  • (C) @app.delete()
  • (D) @delete.route()

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ