1
0

main.py 517 B

123456789101112131415161718192021
  1. from fastapi import FastAPI
  2. app = FastAPI()
  3. @app.get("/")
  4. def read_root():
  5. return {"message": "Hello, World!"}
  6. @app.get("/items")
  7. def get_items():
  8. return {
  9. "items": [
  10. {"id": 1, "name": "item1", "description": "A fancy item", "price": 10.99},
  11. {"id": 2, "name": "item2", "description": "A useful item", "price": 5.49},
  12. {"id": 3, "name": "item3", "description": "A rare item", "price": 99.99},
  13. ]
  14. }
  15. @app.get("/item")
  16. def get_items():
  17. return "item1"