Spaces:
Running
Running
File size: 7,022 Bytes
b72ab63 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
Metadata-Version: 2.1
Name: fastapi-cli
Version: 0.0.4
Summary: Run and manage FastAPI apps from the command line with FastAPI CLI. ๐
Home-page: https://github.com/tiangolo/fastapi-cli
Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
License: MIT
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development
Classifier: Typing :: Typed
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Project-URL: Documentation, https://fastapi.tiangolo.com
Project-URL: Homepage, https://github.com/tiangolo/fastapi-cli
Project-URL: Repository, https://github.com/tiangolo/fastapi-cli
Requires-Python: >=3.8
Requires-Dist: typer>=0.12.3
Requires-Dist: fastapi; extra == "standard"
Requires-Dist: uvicorn[standard]>=0.15.0; extra == "standard"
Provides-Extra: standard
Description-Content-Type: text/markdown
# FastAPI CLI
<a href="https://github.com/tiangolo/fastapi-cli/actions/workflows/test.yml" target="_blank">
<img src="https://github.com/tiangolo/fastapi-cli/actions/workflows/test.yml/badge.svg" alt="Test">
</a>
<a href="https://github.com/tiangolo/fastapi-cli/actions/workflows/publish.yml" target="_blank">
<img src="https://github.com/tiangolo/fastapi-cli/actions/workflows/publish.yml/badge.svg" alt="Publish">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/fastapi-cli" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/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/tiangolo/fastapi-cli" target="_blank">https://github.com/tiangolo/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`), 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.
|