Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
Actively maintained. Last release 2 weeks ago, commits in 17 of the last 26 weeks. A safe choice.
pip install fastapi-cliFastAPI CLI
Source Code: https://github.com/fastapi/fastapi-cli
Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
Description
FastAPI CLI is a command line program fastapi that you can use to serve your FastAPI app, manage your FastAPI project, and more.
When you install FastAPI (e.g. with pip install "fastapi[standard]"), it includes a package called fastapi-cli, this package provides the fastapi command in the terminal.
To run your FastAPI app for development, you can use the fastapi dev command:
$ fastapi dev main.py
FastAPI Starting development server 🚀
Searching for package file structure from directories with __init__.py files
Importing from /home/user/code/awesomeapp
module 🐍 main.py
code Importing the FastAPI app object from the module with the following code:
from main import app
app Using import string: main:app
server Server started at http://127.0.0.1:8000
server Documentation at http://127.0.0.1:8000/docs
tip Running in development mode, for production use: fastapi run
Logs:
INFO Will watch for changes in these directories: ['/home/user/code/awesomeapp']
INFO Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO Started reloader process [4106097] using WatchFiles
INFO Started server process [4106120]
INFO Waiting for application startup.
INFO Application startup complete.
That command line program called fastapi is FastAPI CLI.
FastAPI CLI takes the path to your Python program and automatically detects the variable with the FastAPI (commonly named ) and how to import it, and then serves it.