mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-19 05:53:12 -04:00
🌐 Update translations for ja (update-outdated) (#15171)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Yurii Motov <yurii.motov.monte@gmail.com>
This commit is contained in:
committed by
GitHub
parent
92cc0bd9de
commit
311ce1cfa5
@@ -1,15 +1,15 @@
|
||||
# FastAPI CLI { #fastapi-cli }
|
||||
|
||||
**FastAPI CLI** は、FastAPI アプリの提供、FastAPI プロジェクトの管理などに使用できるコマンドラインプログラムです。
|
||||
**FastAPI <abbr title="command line interface - コマンドラインインターフェース">CLI</abbr>** は、FastAPI アプリの提供、FastAPI プロジェクトの管理などに使用できるコマンドラインプログラムです。
|
||||
|
||||
FastAPI をインストールすると(例: `pip install "fastapi[standard]"`)、`fastapi-cli` というパッケージが含まれます。このパッケージがターミナルで使用する `fastapi` コマンドを提供します。
|
||||
FastAPI をインストールすると(例: `pip install "fastapi[standard]"`)、ターミナルで実行できるコマンドラインプログラムが付属します。
|
||||
|
||||
開発用に FastAPI アプリを起動するには、`fastapi dev` コマンドを使用できます:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:solid">main.py</u>
|
||||
$ <font color="#4E9A06">fastapi</font> dev
|
||||
|
||||
<span style="background-color:#009485"><font color="#D3D7CF"> FastAPI </font></span> Starting development server 🚀
|
||||
|
||||
@@ -46,13 +46,66 @@ $ <font color="#4E9A06">fastapi</font> dev <u style="text-decoration-style:solid
|
||||
|
||||
</div>
|
||||
|
||||
`fastapi` というコマンドラインプログラムが **FastAPI CLI** です。
|
||||
/// tip
|
||||
|
||||
FastAPI CLI は、Python プログラムへのパス(例: `main.py`)を受け取り、`FastAPI` インスタンス(通常は `app`)を自動検出し、適切な import 方法を判断して提供します。
|
||||
本番では `fastapi dev` の代わりに `fastapi run` を使用します。🚀
|
||||
|
||||
本番環境では代わりに `fastapi run` を使用します。🚀
|
||||
///
|
||||
|
||||
内部的には、**FastAPI CLI** は <a href="https://www.uvicorn.dev" class="external-link" target="_blank">Uvicorn</a>(高性能で本番運用向けの ASGI サーバー)を使用します。😎
|
||||
内部的には、**FastAPI CLI** は [Uvicorn](https://www.uvicorn.dev)(高性能で本番運用向けの ASGI サーバー)を使用します。😎
|
||||
|
||||
`fastapi` CLI は、実行する FastAPI アプリを自動検出しようとします。既定では、`main.py` の中にある `app` という名前のオブジェクト(ほかにもいくつかの変種)であると仮定します。
|
||||
|
||||
ただし、使用するアプリを明示的に設定することもできます。
|
||||
|
||||
## `pyproject.toml` でアプリの `entrypoint` を設定 { #configure-the-app-entrypoint-in-pyproject-toml }
|
||||
|
||||
`pyproject.toml` に次のように、アプリの場所を設定できます:
|
||||
|
||||
```toml
|
||||
[tool.fastapi]
|
||||
entrypoint = "main:app"
|
||||
```
|
||||
|
||||
この `entrypoint` により、`fastapi` コマンドは次のようにアプリを import する必要があると認識します:
|
||||
|
||||
```python
|
||||
from main import app
|
||||
```
|
||||
|
||||
もしコード構成が次のような場合:
|
||||
|
||||
```
|
||||
.
|
||||
├── backend
|
||||
│ ├── main.py
|
||||
│ ├── __init__.py
|
||||
```
|
||||
|
||||
`entrypoint` は次のように設定します:
|
||||
|
||||
```toml
|
||||
[tool.fastapi]
|
||||
entrypoint = "backend.main:app"
|
||||
```
|
||||
|
||||
これは次と同等です:
|
||||
|
||||
```python
|
||||
from backend.main import app
|
||||
```
|
||||
|
||||
### パス指定での `fastapi dev` { #fastapi-dev-with-path }
|
||||
|
||||
`fastapi dev` コマンドにファイルパスを渡すこともでき、使用する FastAPI アプリオブジェクトを推測します:
|
||||
|
||||
```console
|
||||
$ fastapi dev main.py
|
||||
```
|
||||
|
||||
ただし、そのたびに `fastapi` コマンドを呼び出す際に正しいパスを渡す必要があります。
|
||||
|
||||
さらに、[VS Code 拡張機能](editor-support.md) や [FastAPI Cloud](https://fastapicloud.com) など、ほかのツールがそれを見つけられない場合があります。そのため、`pyproject.toml` の `entrypoint` を使用することを推奨します。
|
||||
|
||||
## `fastapi dev` { #fastapi-dev }
|
||||
|
||||
@@ -68,8 +121,8 @@ FastAPI CLI は、Python プログラムへのパス(例: `main.py`)を受
|
||||
|
||||
多くの場合(そして推奨されるのは)、上位に HTTPS を終端する「termination proxy」を置きます。これはアプリのデプロイ方法に依存し、プロバイダが代行する場合もあれば、自分で設定する必要がある場合もあります。
|
||||
|
||||
/// tip | 豆知識
|
||||
/// tip
|
||||
|
||||
詳しくは、[デプロイのドキュメント](deployment/index.md){.internal-link target=_blank}を参照してください。
|
||||
詳しくは、[デプロイのドキュメント](deployment/index.md)を参照してください。
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user