fastapi-cli


Namefastapi-cli JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/fastapi/fastapi-cli
SummaryRun and manage FastAPI apps from the command line with FastAPI CLI. 🚀
upload_time2024-08-02 05:48:13
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # FastAPI CLI

<a href="https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml" target="_blank">
    <img src="https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml/badge.svg" alt="Test">
</a>
<a href="https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml" target="_blank">
    <img src="https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/fastapi-cli" target="_blank">
    <img src="https://coverage-badge.samuelcolvin.workers.dev/fastapi/fastapi-cli.svg" alt="Coverage">
<a href="https://pypi.org/project/fastapi-cli" target="_blank">
    <img src="https://img.shields.io/pypi/v/fastapi-cli?color=%2334D058&label=pypi%20package" alt="Package version">
</a>

---

**Source Code**: <a href="https://github.com/fastapi/fastapi-cli" target="_blank">https://github.com/fastapi/fastapi-cli</a>

---

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:

<div class="termy">

```console
$ fastapi dev main.py
INFO     Using path main.py
INFO     Resolved absolute path /home/user/code/awesomeapp/main.py
INFO     Searching for package file structure from directories with __init__.py files
INFO     Importing from /home/user/code/awesomeapp

 ╭─ Python module file ─╮
 │                      │
 │  🐍 main.py          │
 │                      │
 ╰──────────────────────╯

INFO     Importing module main
INFO     Found importable FastAPI app

 ╭─ Importable FastAPI app ─╮
 │                          │
 │  from main import app    │
 │                          │
 ╰──────────────────────────╯

INFO     Using import string main:app

 ╭────────── FastAPI CLI - Development mode ───────────╮
 │                                                     │
 │  Serving at: http://127.0.0.1:8000                  │
 │                                                     │
 │  API docs: http://127.0.0.1:8000/docs               │
 │                                                     │
 │  Running in development mode, for production use:   │
 │                                                     │
 │  fastapi run                                        │
 │                                                     │
 ╰─────────────────────────────────────────────────────╯

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 [56345] using WatchFiles
INFO:     Started server process [56352]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
```

</div>

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 <a href="https://www.uvicorn.org" class="external-link" target="_blank">Uvicorn</a>, 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 <a href="https://fastapi.tiangolo.com/deployment/" class="external-link" target="_blank">FastAPI Deployment documentation</a>.

## License

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/fastapi/fastapi-cli",
    "name": "fastapi-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "=?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c5/f8/1ad5ce32d029aeb9117e9a5a9b3e314a8477525d60c12a9b7730a3c186ec/fastapi_cli-0.0.5.tar.gz",
    "platform": null,
    "description": "# FastAPI CLI\n\n<a href=\"https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml\" target=\"_blank\">\n    <img src=\"https://github.com/fastapi/fastapi-cli/actions/workflows/test.yml/badge.svg\" alt=\"Test\">\n</a>\n<a href=\"https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml\" target=\"_blank\">\n    <img src=\"https://github.com/fastapi/fastapi-cli/actions/workflows/publish.yml/badge.svg\" alt=\"Publish\">\n</a>\n<a href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/fastapi-cli\" target=\"_blank\">\n    <img src=\"https://coverage-badge.samuelcolvin.workers.dev/fastapi/fastapi-cli.svg\" alt=\"Coverage\">\n<a href=\"https://pypi.org/project/fastapi-cli\" target=\"_blank\">\n    <img src=\"https://img.shields.io/pypi/v/fastapi-cli?color=%2334D058&label=pypi%20package\" alt=\"Package version\">\n</a>\n\n---\n\n**Source Code**: <a href=\"https://github.com/fastapi/fastapi-cli\" target=\"_blank\">https://github.com/fastapi/fastapi-cli</a>\n\n---\n\nRun and manage FastAPI apps from the command line with FastAPI CLI. \ud83d\ude80\n\n## Description\n\n**FastAPI CLI** is a command line program `fastapi` that you can use to serve your FastAPI app, manage your FastAPI project, and more.\n\nWhen 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.\n\nTo run your FastAPI app for development, you can use the `fastapi dev` command:\n\n<div class=\"termy\">\n\n```console\n$ fastapi dev main.py\nINFO     Using path main.py\nINFO     Resolved absolute path /home/user/code/awesomeapp/main.py\nINFO     Searching for package file structure from directories with __init__.py files\nINFO     Importing from /home/user/code/awesomeapp\n\n \u256d\u2500 Python module file \u2500\u256e\n \u2502                      \u2502\n \u2502  \ud83d\udc0d main.py          \u2502\n \u2502                      \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\nINFO     Importing module main\nINFO     Found importable FastAPI app\n\n \u256d\u2500 Importable FastAPI app \u2500\u256e\n \u2502                          \u2502\n \u2502  from main import app    \u2502\n \u2502                          \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\nINFO     Using import string main:app\n\n \u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 FastAPI CLI - Development mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n \u2502                                                     \u2502\n \u2502  Serving at: http://127.0.0.1:8000                  \u2502\n \u2502                                                     \u2502\n \u2502  API docs: http://127.0.0.1:8000/docs               \u2502\n \u2502                                                     \u2502\n \u2502  Running in development mode, for production use:   \u2502\n \u2502                                                     \u2502\n \u2502  fastapi run                                        \u2502\n \u2502                                                     \u2502\n \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\n\nINFO:     Will watch for changes in these directories: ['/home/user/code/awesomeapp']\nINFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [56345] using WatchFiles\nINFO:     Started server process [56352]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n```\n\n</div>\n\nThat command line program called `fastapi` is **FastAPI CLI**.\n\nFastAPI 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.\n\nFor production you would use `fastapi run` instead. \ud83d\ude80\n\nInternally, **FastAPI CLI** uses <a href=\"https://www.uvicorn.org\" class=\"external-link\" target=\"_blank\">Uvicorn</a>, a high-performance, production-ready, ASGI server. \ud83d\ude0e\n\n## `fastapi dev`\n\nWhen you run `fastapi dev`, it will run on development mode.\n\nBy 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.\n\nBy 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`).\n\n## `fastapi run`\n\nWhen you run `fastapi run`, it will run on production mode by default.\n\nIt will have **auto-reload disabled** by default.\n\nIt 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.\n\nIn 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 <a href=\"https://fastapi.tiangolo.com/deployment/\" class=\"external-link\" target=\"_blank\">FastAPI Deployment documentation</a>.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Run and manage FastAPI apps from the command line with FastAPI CLI. \ud83d\ude80",
    "version": "0.0.5",
    "project_urls": {
        "Documentation": "https://fastapi.tiangolo.com",
        "Homepage": "https://github.com/fastapi/fastapi-cli",
        "Repository": "https://github.com/fastapi/fastapi-cli"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24ea4b5011012ac925fe2f83b19d0e09cee9d324141ec7bf5e78bb2817f96513",
                "md5": "3948755ca42df20878aa2ac8e4e864f2",
                "sha256": "e94d847524648c748a5350673546bbf9bcaeb086b33c24f2e82e021436866a46"
            },
            "downloads": -1,
            "filename": "fastapi_cli-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3948755ca42df20878aa2ac8e4e864f2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9489,
            "upload_time": "2024-08-02T05:48:11",
            "upload_time_iso_8601": "2024-08-02T05:48:11.609410Z",
            "url": "https://files.pythonhosted.org/packages/24/ea/4b5011012ac925fe2f83b19d0e09cee9d324141ec7bf5e78bb2817f96513/fastapi_cli-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c5f81ad5ce32d029aeb9117e9a5a9b3e314a8477525d60c12a9b7730a3c186ec",
                "md5": "52208de812edb476d5f8add988c4dd52",
                "sha256": "d30e1239c6f46fcb95e606f02cdda59a1e2fa778a54b64686b3ff27f6211ff9f"
            },
            "downloads": -1,
            "filename": "fastapi_cli-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "52208de812edb476d5f8add988c4dd52",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15571,
            "upload_time": "2024-08-02T05:48:13",
            "upload_time_iso_8601": "2024-08-02T05:48:13.160013Z",
            "url": "https://files.pythonhosted.org/packages/c5/f8/1ad5ce32d029aeb9117e9a5a9b3e314a8477525d60c12a9b7730a3c186ec/fastapi_cli-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-02 05:48:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fastapi",
    "github_project": "fastapi-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "fastapi-cli"
}
        
Elapsed time: 0.30395s