Skip to main content

Общие команды

Установка:

pip install fastapi uvicorn

Ручной запуск (api - имя файла, app - имя объекта FastApi)

uvicorn api:app --port 8000 --reload

curl запросы

curl -X 'GET' 'http://127.0.0.1:8000/todo' -H 'accept: application/json' 
curl -X 'POST' \ 
'http://127.0.0.1:8000/todo' \ 
-H 'accept: application/json' \ 
-H 'Content-Type: application/json' \ 
-d '{ 
"id": 1, 
"item": "First Todo is to finish this book!" 
}'

Автоматическая документация

Swagger

http://ip:port/docs

Redoc

http://ip:port/redoc