Path Operations
from fastapi import FastAPI
# Defining the FastAPI() function
app = FastAPI()
# You need to use a decorator to "activate" the FastAPI logic
# Otherwise it's just a plain python function
@app.get("/") # This is a http method (GET)
# The function itself
def root():
# In true pythonic fashion, function will return result
return {"message": "Hello World"}@app.get("/") # Root path
Resources:
Last updated