Skip to content

Instantly share code, notes, and snippets.

@vndee
Last active October 19, 2022 08:21
Show Gist options
  • Save vndee/82c1d2b7df6471a0f53abcbd0262890a to your computer and use it in GitHub Desktop.
Save vndee/82c1d2b7df6471a0f53abcbd0262890a to your computer and use it in GitHub Desktop.
from fastapi import FastAPI, Response
from fastapi.responses import JSONResponse
app = FastAPI(title="Demo REST Server")
@app.get("/hello")
async def hello() -> Response:
return JSONResponse({"message": "Hello, World"})
@app.get("/get_user/{user_id}")
async def get_user(user_id: int) -> Response:
return JSONResponse({"message": f"You requested data of {user_id}"})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment