Fast API MCQs with answers Page - 17

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 define default values for query parameters in FastAPI?

  • (A) query=Default(value)
  • (B) query: str = 'value'
  • (C) query: str = Query(default='value')
  • (D) All of the above

R

Ravina • 3.96K Points
Extraordinary

Q. How do you serve static files using FastAPI?

  • (A) app.serve_static()
  • (B) app.use_static()
  • (C) StaticFiles from starlette.staticfiles
  • (D) StaticHandler

R

Ravina • 3.96K Points
Extraordinary

Q. What is returned by default if no response model is defined in FastAPI?

  • (A) Plain text
  • (B) JSON
  • (C) HTML
  • (D) XML

R

Ravina • 3.96K Points
Extraordinary

Q. Which of the following is used to set CORS in FastAPI?

  • (A) AllowOrigin
  • (B) CORS
  • (C) CORSMiddleware
  • (D) CorsSupport

R

Ravina • 3.96K Points
Extraordinary

Q. How do you return a redirect response in FastAPI?

  • (A) RedirectResponse
  • (B) HTTPRedirect
  • (C) ReturnRedirect
  • (D) send_redirect

R

Ravina • 3.96K Points
Extraordinary

Q. How can you extract a path parameter in FastAPI?

  • (A) Using `Path()`
  • (B) Using `Header()`
  • (C) Using `Body()`
  • (D) Using `Field()`

R

Ravina • 3.96K Points
Extraordinary

Q. What is the default OpenAPI version used by FastAPI?

  • (A) 2.0.0
  • (B) 3.0.0
  • (C) 3.1.0
  • (D) 2.1.0

R

Ravina • 3.96K Points
Extraordinary

Q. Which FastAPI class allows multiple routes to be grouped together?

  • (A) RouteManager
  • (B) Router
  • (C) APIRouter
  • (D) RouteGroup

R

Ravina • 3.96K Points
Extraordinary

Q. How does FastAPI know which values to inject into parameters?

  • (A) Based on parameter order
  • (B) From decorators
  • (C) Using type hints and annotations
  • (D) From default values

R

Ravina • 3.96K Points
Extraordinary

Q. Which method allows handling WebSockets in FastAPI?

  • (A) @app.websocket()
  • (B) @app.ws()
  • (C) @app.socket()
  • (D) @app.websocket_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