You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FastAPI CLI is a robust command-line interface designed for FastAPI applications. It streamlines both development and production deployments by providing automatic reload capabilities and leveraging Uvicorn's high-performance ASGI server.
- ⚡️ **High Performance** - Built on Uvicorn's lightning-fast ASGI server implementation
19
+
- 🔄 **Development Mode** - Automatic reload support for efficient development
20
+
- 🚀 **Production Ready** - Production-optimized settings with multi-worker support
21
+
- 🔍 **Smart Discovery** - Automatic detection of FastAPI applications
22
+
- 🛠️ **Flexible Configuration** - Comprehensive server configuration options
23
+
- 💻 **Developer Experience** - Intuitive CLI with clear feedback and logging
20
24
21
-
Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
25
+
## Installation
22
26
23
-
## Description
27
+
Select the installation option that matches your requirements:
24
28
25
-
**FastAPI CLI** is a command line program `fastapi` that you can use to serve your FastAPI app, manage your FastAPI project, and more.
29
+
```bash
30
+
# Complete installation with all features
31
+
pip install "fastapi[all]"
26
32
27
-
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.
33
+
# Standard installation with Uvicorn
34
+
pip install "fastapi[standard]"
28
35
29
-
To run your FastAPI app for development, you can use the `fastapi dev` command:
30
-
31
-
<divclass="termy">
36
+
# Basic installation
37
+
pip install fastapi-cli
38
+
```
32
39
33
-
```console
34
-
$ fastapi dev main.py
35
-
INFO Using path main.py
36
-
INFO Resolved absolute path /home/user/code/awesomeapp/main.py
37
-
INFO Searching for package file structure from directories with __init__.py files
38
-
INFO Importing from /home/user/code/awesomeapp
40
+
## Quick Start Guide
39
41
40
-
╭─ Python module file ─╮
41
-
│ │
42
-
│ 🐍 main.py │
43
-
│ │
44
-
╰──────────────────────╯
42
+
### Development Environment
45
43
46
-
INFO Importing module main
47
-
INFO Found importable FastAPI app
44
+
Start your FastAPI application with development features enabled:
48
45
49
-
╭─ Importable FastAPI app ─╮
50
-
│ │
51
-
│ from main import app │
52
-
│ │
53
-
╰──────────────────────────╯
46
+
```bash
47
+
fastapi dev main.py
48
+
```
54
49
55
-
INFO Using import string main:app
50
+
Development server features:
51
+
- Automatic code reloading
52
+
- Local development host (127.0.0.1)
53
+
- Detailed debugging output
54
+
- Enhanced error reporting
56
55
56
+
```
57
57
╭────────── FastAPI CLI - Development mode ───────────╮
58
58
│ │
59
59
│ Serving at: http://127.0.0.1:8000 │
@@ -65,43 +65,119 @@ INFO Using import string main:app
INFO: Will watch for changes in these directories: ['/home/user/code/awesomeapp']
70
-
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
71
-
INFO: Started reloader process [56345] using WatchFiles
72
-
INFO: Started server process [56352]
73
-
INFO: Waiting for application startup.
74
-
INFO: Application startup complete.
70
+
### Production Deployment
71
+
72
+
Launch your application in production mode with optimized settings:
73
+
74
+
```bash
75
+
fastapi run main.py
75
76
```
76
77
77
-
</div>
78
+
Production environment features:
79
+
- Performance-optimized configuration
80
+
- Multi-worker process support
81
+
- Public network interface (0.0.0.0)
82
+
- Production-grade error handling
78
83
79
-
That command line program called `fastapi` is **FastAPI CLI**.
84
+
## Advanced Configuration
80
85
81
-
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.
86
+
### Application Discovery System
82
87
83
-
For production you would use `fastapi run` instead. 🚀
88
+
FastAPI CLI implements an intelligent application discovery system with the following search hierarchy:
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.
129
+
-**Uvicorn Engine**
130
+
- High-performance ASGI server implementation
131
+
- Production-grade server capabilities
132
+
- WebSocket protocol support
133
+
- HTTP/1.1 and HTTP/2 protocol support
92
134
93
-
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`).
135
+
-**FastAPI Framework**
136
+
- Modern Python web framework (Python 3.8+)
137
+
- Type hint-based validation
138
+
- Automatic OpenAPI documentation
139
+
- Built-in async support
140
+
- Advanced dependency injection
94
141
95
-
## `fastapi run`
142
+
## Best Practices
96
143
97
-
When you run `fastapi run`, it will run on production mode by default.
144
+
### Development Guidelines
145
+
- Use `fastapi dev` for development workflows
146
+
- Enable comprehensive logging during debugging
147
+
- Leverage automatic API documentation
148
+
- Implement proper error handling
98
149
99
-
It will have **auto-reload disabled** by default.
150
+
### Production Guidelines
151
+
- Deploy with `fastapi run` and appropriate worker configuration
152
+
- Configure network settings based on deployment environment
153
+
- Implement security best practices
154
+
- Use a production-grade reverse proxy (e.g., Nginx)
100
155
101
-
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.
156
+
## Contributing
102
157
103
-
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 <ahref="https://fastapi.tiangolo.com/deployment/"class="external-link"target="_blank">FastAPI Deployment documentation</a>.
158
+
We welcome community contributions! See our [Contributing Guidelines](CONTRIBUTING.md) for:
159
+
- Code style requirements
160
+
- Development environment setup
161
+
- Pull request workflow
162
+
- Issue reporting guidelines
163
+
164
+
## Security
165
+
166
+
Security is a top priority. Review our [Security Policy](SECURITY.md) for:
167
+
- Version support information
168
+
- Security update policies
169
+
- Vulnerability reporting procedures
170
+
- Security best practices
104
171
105
172
## License
106
173
107
-
This project is licensed under the terms of the MIT license.
174
+
This project is released under the MIT License. See the [LICENSE](LICENSE) file for complete details.
0 commit comments