Skip to content

Instantly share code, notes, and snippets.

@anshajk
Created August 20, 2025 14:01
Show Gist options
  • Save anshajk/a5091211c4e33530742c9e14782dd31a to your computer and use it in GitHub Desktop.
Save anshajk/a5091211c4e33530742c9e14782dd31a to your computer and use it in GitHub Desktop.
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, FastAPI!"}
# Greet user by name
@app.get("/greet/{name}")
def greet_user(name: str):
return {"greeting": f"Hello, {name}!"}
# Add two numbers
@app.get("/add")
def add_numbers(a: int, b: int):
return {"result": a + b}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment