FastAPI
Setup Development Environment#
Prerequisite#
I have Python 3.12.2 installed on Mac.
Package and Dependency Management#
We can use Poetry for Python packaging and dependency management. We need to install pipx
first.
Install poetry:
Check version:
Open a new terminal and run:
For formatting source code:
Testing#
For testing:
FastAPI Setup#
Install FastAPI framework:
An asynchronous web server:
To hit the API from the terminal:
A synchronous web client package:
A synchronous/asynchronous web client package
Hello FastAPI#
We can now check our development setup. Create a hi.py
file:
View the response in the browser at: http://127.0.0.1:8000/
Command Line HTTP Client#
Use http in the terminal: