Skip to content

Commit c67f69f

Browse files
committed
📝 Update README
1 parent 444ec71 commit c67f69f

File tree

1 file changed

+84
-4
lines changed

1 file changed

+84
-4
lines changed

README.md

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# FastAPI CLI
22

3-
<a href="https://github.com/tiangolo/fastapi-cli/actions?query=workflow%3ATest" target="_blank">
4-
<img src="https://github.com/tiangolo/fastapi-cli/workflows/Test/badge.svg" alt="Test">
3+
<a href="https://github.com/tiangolo/fastapi-cli/actions/workflows/test.yml" target="_blank">
4+
<img src="https://github.com/tiangolo/fastapi-cli/actions/workflows/test.yml/badge.svg" alt="Test">
55
</a>
6-
<a href="https://github.com/tiangolo/fastapi-cli/actions?query=workflow%3APublish" target="_blank">
7-
<img src="https://github.com/tiangolo/fastapi-cli/workflows/Publish/badge.svg" alt="Publish">
6+
<a href="https://github.com/tiangolo/fastapi-cli/actions/workflows/publish.yml" target="_blank">
7+
<img src="https://github.com/tiangolo/fastapi-cli/actions/workflows/publish.yml/badge.svg" alt="Publish">
88
</a>
99
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/tiangolo/fastapi-cli" target="_blank">
1010
<img src="https://coverage-badge.samuelcolvin.workers.dev/tiangolo/fastapi-cli.svg" alt="Coverage">
@@ -20,6 +20,86 @@
2020

2121
Run FastAPI applications from the command line with FastAPI CLI. 🚀
2222

23+
## Description
24+
25+
**FastAPI CLI** is a command line program `fastapi` that you can use to serve your FastAPI app, manage your FastAPI project, and more.
26+
27+
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.
28+
29+
To run your FastAPI app for development, you can use the `fastapi dev` command:
30+
31+
<div class="termy">
32+
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
39+
40+
╭─ Python module file ─╮
41+
│ │
42+
│ 🐍 main.py │
43+
│ │
44+
╰──────────────────────╯
45+
46+
INFO Importing module main
47+
INFO Found importable FastAPI app
48+
49+
╭─ Importable FastAPI app ─╮
50+
│ │
51+
│ from main import app │
52+
│ │
53+
╰──────────────────────────╯
54+
55+
INFO Using import string main:app
56+
57+
╭────────── FastAPI CLI - Development mode ───────────╮
58+
│ │
59+
│ Serving at: http://127.0.0.1:8000 │
60+
│ │
61+
│ API docs: http://127.0.0.1:8000/docs │
62+
│ │
63+
│ Running in development mode, for production use: │
64+
│ │
65+
│ fastapi run │
66+
│ │
67+
╰─────────────────────────────────────────────────────╯
68+
69+
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.
75+
```
76+
77+
</div>
78+
79+
That command line program called `fastapi` is **FastAPI CLI**.
80+
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.
82+
83+
For production you would use `fastapi run` instead. 🚀
84+
85+
## `fastapi dev`
86+
87+
When you run `fastapi dev`, it will run on development mode.
88+
89+
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.
90+
91+
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`).
92+
93+
## `fastapi run`
94+
95+
When you run `fastapi run`, it will run on production mode by default.
96+
97+
It will have **auto-reload disabled** by default.
98+
99+
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.
100+
101+
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>.
102+
23103
## License
24104

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

0 commit comments

Comments
 (0)