0
0
FastAPIframework~10 mins

FastAPI vs Flask vs Django comparison - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a FastAPI app instance.

FastAPI
from fastapi import [1]
app = [1]()
Drag options to blanks, or click blank then click option'
ARequest
BFlask
CDjango
DFastAPI
Attempts:
3 left
💡 Hint
Common Mistakes
Using Flask or Django classes instead of FastAPI.
Forgetting to instantiate the app.
2fill in blank
medium

Complete the code to define a route in Flask.

FastAPI
from flask import Flask
app = Flask(__name__)

@app.route([1])
def home():
    return "Hello from Flask!"
Drag options to blanks, or click blank then click option'
A"/"
B"/home"
C"/index.html"
D"/api"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-root path when the question asks for the main route.
Forgetting quotes around the route string.
3fill in blank
hard

Fix the error in this Django view function to return a simple HTTP response.

FastAPI
from django.http import HttpResponse

def home(request):
    return [1]("Hello from Django!")
Drag options to blanks, or click blank then click option'
AHttpResponse
Brender
Credirect
DJsonResponse
Attempts:
3 left
💡 Hint
Common Mistakes
Using render without a template.
Returning a string directly instead of an HttpResponse.
4fill in blank
hard

Fill both blanks to create a FastAPI GET endpoint that returns a greeting.

FastAPI
from fastapi import FastAPI
app = FastAPI()

@app.[1]("/greet")
def greet():
    return [2]
Drag options to blanks, or click blank then click option'
Aget
Bpost
C{"message": "Hello!"}
D"Hello!"
Attempts:
3 left
💡 Hint
Common Mistakes
Using post decorator for a GET endpoint.
Returning a plain string instead of a dictionary for JSON.
5fill in blank
hard

Fill all three blanks to create a Django URL pattern for the home view.

FastAPI
from django.urls import path
from .views import home

urlpatterns = [
    path([1], [2], name=[3])
]
Drag options to blanks, or click blank then click option'
A""
Bhome
C"home"
D"/"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "/" instead of empty string for root path.
Not quoting the route name string.