2.1. About

2.1.1. Rationale

  • Path

  • Operation

  • Path Operation Function

  • Path Operation Decorator

  • Routing

  • Order of Path Operation Functions matters

  • Tags are identifiers used to group routes. Routes with the same tags are grouped into a section on the API documentation.

>>> from fastapi import FastAPI
>>> app = FastAPI()
>>>
>>>
>>> @app.get('/hello')
... def hello():
...     return {'message': 'hello'}
>>>
>>>
>>> @app.get('/ehlo')
... def ehlo():
...     return {'message': 'ehlo'}

2.1.2. Operation

  • app.get()

  • get

  • post

  • put

  • delete

  • head

2.1.3. Path

  • '/'

2.1.4. Path Operation Decorator

  • @app.get('/')

2.1.5. Path Operation Function

>>> def hello():
...     return {'message': 'hello world'}