4.1. About

4.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'}

4.1.2. Operation

  • app.get()

  • app.post()

  • app.put()

  • app.delete()

  • app.head()

4.1.3. Path

  • / - URI

4.1.4. Path Operation Decorator

  • @app.get('/')

4.1.5. Path Operation Function

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