- install python and create directory
If you haven't already installed Python, you can do so using Homebrew Create a directory where you'll store your FastAPI project. You can name it whatever you like. For example:
brew install python
mkdir fastapi
cd fastapi - Create a Virtual Environment
Create a virtual environment using Python's built-in venv module inside your project directory
python -m venv env- Activate the Virtual Environment
source env/bin/activate # Mac OS
.\env\Scripts\activate # Windows - Install Uvicorn and FastAPI
pip3 install uvicorn fastapi -
Start the FastAPI tutorial
-
Deactivate the Virtual Environment (Optional)
When you're done working on your FastAPI project, you can deactivate the virtual environment using:
deactivate Activate Python Virtual Environment
source env/bin/activate # Mac OS
.\env\Scripts\activate # Windows Run uvicorn
uvicorn main:app --reload Documentation Link based on OpenAPI Standard
Open http://127.0.0.1:8000/docs
FastAPI alternative API documation by ReDoc
Finish Python Virtual Environment
deactivate