Spaces:
Sleeping
Sleeping
File size: 18,460 Bytes
a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a48afb9 a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a152b95 a48afb9 a152b95 520796c a48afb9 c378584 a48afb9 c378584 520796c a48afb9 c378584 a48afb9 c378584 520796c a48afb9 c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c a48afb9 c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c a48afb9 c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c a48afb9 c378584 a48afb9 c378584 520796c c378584 a48afb9 c378584 520796c a48afb9 a152b95 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | [
{
"id": "q001",
"question": "How do you define a path parameter in FastAPI?",
"expected_answer_keywords": [
"curly braces",
"path",
"function parameter",
"URL"
],
"expected_sources": [
"fastapi_path_params.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "Path parameters in FastAPI are defined using curly braces {} in the route path string, with a corresponding parameter in the function signature."
},
{
"id": "q002",
"question": "What is the default page size for pagination in FastAPI and what is the maximum allowed?",
"expected_answer_keywords": [
"20",
"100",
"default",
"maximum"
],
"expected_sources": [
"fastapi_pagination.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "The default page size for pagination in FastAPI is 20 items per page, and the maximum allowed page size is 100."
},
{
"id": "q003",
"question": "How does FastAPI handle CORS and what is the default max_age for preflight caching?",
"expected_answer_keywords": [
"CORSMiddleware",
"600",
"seconds",
"preflight"
],
"expected_sources": [
"fastapi_middleware.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "FastAPI handles CORS by adding CORSMiddleware to the application, which manages preflight requests. The default max_age for preflight caching is 600 seconds."
},
{
"id": "q004",
"question": "What algorithm and expiry time does the FastAPI security example use for JWT tokens?",
"expected_answer_keywords": [
"HS256",
"30",
"minutes"
],
"expected_sources": [
"fastapi_security.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "The FastAPI security example uses the HS256 algorithm for JWT tokens with an expiry time of 30 minutes."
},
{
"id": "q005",
"question": "What is the recommended formula for calculating the number of Gunicorn workers for a FastAPI deployment?",
"expected_answer_keywords": [
"2",
"CPU",
"cores",
"1"
],
"expected_sources": [
"fastapi_deployment.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "The recommended formula for calculating Gunicorn workers is (2 * CPU cores) + 1."
},
{
"id": "q006",
"question": "How does dependency caching work in FastAPI, and how can you disable it?",
"expected_answer_keywords": [
"cache",
"once",
"use_cache",
"False"
],
"expected_sources": [
"fastapi_dependencies.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "FastAPI caches dependency results so each dependency is called only once per request. Caching can be disabled by setting use_cache=False in the Depends() call.",
"source_snippets": [
"By default, if the same dependency is used multiple times within a single request (e.g., both a route and a sub-dependency use `Depends(get_db)`), FastAPI caches the result and calls the dependency only once. To disable caching and force a fresh call each time, use `Depends(get_db, use_cache=False)`."
]
},
{
"id": "q007",
"question": "If a paginated endpoint returns 20 items per page and there are 10,000 items total, how many total pages are there? And if the page size is changed to 30, how many pages would there be?",
"expected_answer_keywords": [
"500",
"334",
"ceil",
"pages"
],
"expected_sources": [
"fastapi_pagination.md"
],
"category": "calculation",
"difficulty": "medium",
"requires_calculator": true,
"reference_answer": "With 10,000 items at 20 per page, there are 500 total pages (10000/20). At 30 per page, there are 334 pages (ceil(10000/30))."
},
{
"id": "q008",
"question": "Does FastAPI support automatic Kubernetes deployment?",
"expected_answer_keywords": [
"not",
"does not contain",
"no information"
],
"expected_sources": [],
"category": "out_of_scope",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": ""
},
{
"id": "q009",
"question": "How does FastAPI integrate with Apache Kafka for event streaming?",
"expected_answer_keywords": [
"not",
"does not contain",
"no information"
],
"expected_sources": [],
"category": "out_of_scope",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": ""
},
{
"id": "q010",
"question": "Can FastAPI generate GraphQL schemas natively?",
"expected_answer_keywords": [
"not",
"does not contain",
"no information"
],
"expected_sources": [],
"category": "out_of_scope",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "",
"source_snippets": []
},
{
"id": "q011",
"question": "What is the default Swagger UI endpoint in FastAPI?",
"expected_answer_keywords": [
"/docs",
"Swagger",
"interactive"
],
"expected_sources": [
"fastapi_openapi.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "The default Swagger UI endpoint in FastAPI is /docs, which provides an interactive API documentation interface.",
"source_snippets": [
"| `/docs` | Swagger UI -- interactive API explorer |",
"Every FastAPI application exposes three documentation-related endpoints by default:"
]
},
{
"id": "q012",
"question": "How do you raise an HTTP error in a FastAPI route handler?",
"expected_answer_keywords": [
"HTTPException",
"status_code",
"detail"
],
"expected_sources": [
"fastapi_error_handling.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "You raise an HTTP error in FastAPI by raising an HTTPException with a status_code and a detail message describing the error.",
"source_snippets": [
"The `HTTPException` class is the primary way to return error responses from route handlers:",
"When raised, `HTTPException` immediately terminates request processing and returns the specified status code and detail message. The `detail` parameter can be a string, list, or dictionary -- FastAPI serializes it to JSON automatically."
]
},
{
"id": "q013",
"question": "How do you define a request body in FastAPI?",
"expected_answer_keywords": [
"Pydantic",
"BaseModel",
"JSON"
],
"expected_sources": [
"fastapi_request_body.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "Request bodies in FastAPI are defined by creating a Pydantic BaseModel class, which FastAPI automatically parses from the incoming JSON request body."
},
{
"id": "q014",
"question": "What testing tools does FastAPI use, and what class provides the test client?",
"expected_answer_keywords": [
"TestClient",
"pytest",
"Starlette"
],
"expected_sources": [
"fastapi_testing.md"
],
"category": "retrieval",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "FastAPI uses pytest for testing, and the TestClient class (provided by Starlette) is used to simulate HTTP requests to the application."
},
{
"id": "q015",
"question": "How does FastAPI manage application configuration and environment variables?",
"expected_answer_keywords": [
"BaseSettings",
"pydantic",
"env",
"environment"
],
"expected_sources": [
"fastapi_configuration.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "FastAPI manages configuration using Pydantic's BaseSettings class, which automatically reads values from environment variables and supports .env files."
},
{
"id": "q016",
"question": "What is the minimum response size for GZip compression middleware in FastAPI, and how do you enable it?",
"expected_answer_keywords": [
"500",
"bytes",
"GZipMiddleware",
"minimum_size"
],
"expected_sources": [
"fastapi_middleware.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "GZip compression is enabled by adding GZipMiddleware to the application with a minimum_size parameter. The default minimum response size is 500 bytes."
},
{
"id": "q017",
"question": "How do yield dependencies work in FastAPI and what is the maximum number supported per request?",
"expected_answer_keywords": [
"yield",
"cleanup",
"finally",
"32"
],
"expected_sources": [
"fastapi_dependencies.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "Yield dependencies in FastAPI execute code before yielding a value and run cleanup code in a finally block after the response is sent. The maximum number of yield dependencies per request is 32."
},
{
"id": "q018",
"question": "What are the three documentation endpoints FastAPI exposes by default and what OpenAPI version does it use?",
"expected_answer_keywords": [
"/docs",
"/redoc",
"/openapi.json",
"3.1"
],
"expected_sources": [
"fastapi_openapi.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "FastAPI exposes three documentation endpoints by default: /docs (Swagger UI), /redoc (ReDoc), and /openapi.json (the raw OpenAPI schema). It uses OpenAPI version 3.1."
},
{
"id": "q019",
"question": "How does FastAPI handle WebSocket connections, and what must be called before sending data?",
"expected_answer_keywords": [
"accept",
"WebSocket",
"send",
"receive"
],
"expected_sources": [
"fastapi_websockets.md"
],
"category": "retrieval",
"difficulty": "medium",
"requires_calculator": false,
"reference_answer": "FastAPI handles WebSocket connections using the WebSocket class. You must call await websocket.accept() before sending or receiving any data."
},
{
"id": "q020",
"question": "For a server with 4 CPU cores, how many Gunicorn workers should be configured using the recommended formula?",
"expected_answer_keywords": [
"9",
"workers",
"2",
"CPU",
"1"
],
"expected_sources": [
"fastapi_deployment.md"
],
"category": "calculation",
"difficulty": "medium",
"requires_calculator": true,
"reference_answer": "Using the recommended formula (2 * CPU cores) + 1, a server with 4 CPU cores should be configured with 9 Gunicorn workers (2 * 4 + 1 = 9)."
},
{
"id": "q021",
"question": "If the CORS max_age is 600 seconds, how many minutes does the browser cache preflight results?",
"expected_answer_keywords": [
"10",
"minutes"
],
"expected_sources": [
"fastapi_middleware.md"
],
"category": "calculation",
"difficulty": "easy",
"requires_calculator": true,
"reference_answer": "With a CORS max_age of 600 seconds, the browser caches preflight results for 10 minutes (600 / 60 = 10).",
"source_snippets": [
"| `max_age` | `600` | Seconds the browser caches preflight results |"
]
},
{
"id": "q022",
"question": "How do route ordering and dependency injection interact when building a secure FastAPI application with scoped endpoints?",
"expected_answer_keywords": [
"order",
"Depends",
"Security",
"scopes"
],
"expected_sources": [
"fastapi_path_params.md",
"fastapi_dependencies.md",
"fastapi_security.md"
],
"category": "retrieval",
"difficulty": "hard",
"requires_calculator": false,
"reference_answer": "In FastAPI, route ordering matters because more specific routes must be defined before general ones. Security scopes are enforced via the Security() dependency (similar to Depends()), allowing fine-grained access control on scoped endpoints."
},
{
"id": "q023",
"question": "How would you set up a FastAPI application with custom error handling, CORS middleware, and structured testing including dependency overrides?",
"expected_answer_keywords": [
"HTTPException",
"CORSMiddleware",
"TestClient",
"override"
],
"expected_sources": [
"fastapi_error_handling.md",
"fastapi_middleware.md",
"fastapi_testing.md"
],
"category": "retrieval",
"difficulty": "hard",
"requires_calculator": false,
"reference_answer": "Custom error handling is set up by raising HTTPException or registering exception handlers, CORS is configured by adding CORSMiddleware with allowed origins, and testing uses TestClient with app.dependency_overrides to replace dependencies during tests.",
"source_snippets": [
"The `HTTPException` class is the primary way to return error responses from route handlers:",
"Cross-Origin Resource Sharing (CORS) is configured using `CORSMiddleware` from Starlette:"
]
},
{
"id": "q024",
"question": "Explain how to deploy a FastAPI app with Docker using Gunicorn workers, health checks, and environment-based configuration via Pydantic Settings.",
"expected_answer_keywords": [
"Docker",
"Gunicorn",
"health",
"BaseSettings",
"env"
],
"expected_sources": [
"fastapi_deployment.md",
"fastapi_configuration.md"
],
"category": "retrieval",
"difficulty": "hard",
"requires_calculator": false,
"reference_answer": "A FastAPI app is deployed in Docker with Gunicorn as the process manager using the recommended worker formula. Health check endpoints verify application status, and environment-based configuration is managed via Pydantic BaseSettings which reads environment variables and .env files."
},
{
"id": "q025",
"question": "How would you build a paginated API with cursor-based navigation, response model validation, and background task processing for analytics logging?",
"expected_answer_keywords": [
"cursor",
"response_model",
"BackgroundTasks"
],
"expected_sources": [
"fastapi_pagination.md",
"fastapi_response_model.md",
"fastapi_background_tasks.md"
],
"category": "retrieval",
"difficulty": "hard",
"requires_calculator": false,
"reference_answer": "Cursor-based pagination uses an opaque cursor token for navigation instead of page numbers. Response models are validated using the response_model parameter on route decorators, and analytics logging is handled asynchronously via FastAPI's BackgroundTasks dependency.",
"source_snippets": [
"Cursor-based pagination uses an opaque token (cursor) pointing to the last item in the previous page. This avoids the performance degradation of large offsets:"
]
},
{
"id": "q026",
"question": "Does FastAPI have built-in support for database migrations like Alembic?",
"expected_answer_keywords": [
"not",
"does not contain",
"no information"
],
"expected_sources": [],
"category": "out_of_scope",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": ""
},
{
"id": "q027",
"question": "How does FastAPI handle automatic load balancing across multiple servers?",
"expected_answer_keywords": [
"not",
"does not contain",
"no information"
],
"expected_sources": [],
"category": "out_of_scope",
"difficulty": "easy",
"requires_calculator": false,
"reference_answer": "",
"source_snippets": []
}
]
|