Skip to main content

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀

Project description

FastAPI CLI

Test Publish Coverage Package version

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 app) and how to import it, and then serves it.

For production you would use fastapi run instead. 🚀

Internally, FastAPI CLI uses Uvicorn, a high-performance, production-ready, ASGI server. 😎

fastapi dev

When you run fastapi dev, it will run on development mode.

By default, it will have auto-reload enabled, so it will automatically reload the server when you make changes to your code. This is resource intensive and could be less stable than without it, you should only use it for development.

By default it will listen on the IP address 127.0.0.1, which is the IP for your machine to communicate with itself alone (localhost).

fastapi run

When you run fastapi run, it will run on production mode by default.

It will have auto-reload disabled by default.

It will listen on the IP address 0.0.0.0, which means all the available IP addresses, this way it will be publicly accessible to anyone that can communicate with the machine. This is how you would normally run it in production, for example, in a container.

In most cases you would (and should) have a "termination proxy" handling HTTPS for you on top, this will depend on how you deploy your application, your provider might do this for you, or you might need to set it up yourself. You can learn more about it in the FastAPI Deployment documentation.

License

This project is licensed under the terms of the MIT license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_cli_slim-0.0.20.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_cli_slim-0.0.20-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_cli_slim-0.0.20.tar.gz.

File metadata

  • Download URL: fastapi_cli_slim-0.0.20.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fastapi_cli_slim-0.0.20.tar.gz
Algorithm Hash digest
SHA256 3e7acc10dc85f8ba42fb26bd265b4e1687afcef889e4e93a62d6cd8bf7d7f05b
MD5 a184061233522d95cafb1aefd0487d99
BLAKE2b-256 bf3f5ef16be0bc9d2797f3725b79a125cf5310719b5b0658ee734f084925b820

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_cli_slim-0.0.20.tar.gz:

Publisher: publish.yml on fastapi/fastapi-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastapi_cli_slim-0.0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_cli_slim-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 bd7544df486274ea4b844eb9b993e3897dedce4119746d2b339a9855651b71af
MD5 d188d9dd8a73e427f7b33569d01165f1
BLAKE2b-256 5e6603fec232b4b19ce095bbda879f5665d65d0d969697442249ed6b83d90542

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastapi_cli_slim-0.0.20-py3-none-any.whl:

Publisher: publish.yml on fastapi/fastapi-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page