|
|
|
@ -180,7 +180,7 @@ entrypoint = "backend.main:app" |
|
|
|
from backend.main import app |
|
|
|
``` |
|
|
|
|
|
|
|
### パス付きの`fastapi dev` { #fastapi-dev-with-path } |
|
|
|
### パス指定の`fastapi dev`または`--entrypoint` CLIオプション { #fastapi-dev-with-path-or-with-entrypoint-cli-option } |
|
|
|
|
|
|
|
`fastapi dev`コマンドにファイルパスを渡すこともでき、使用すべきFastAPIのappオブジェクトを推測します: |
|
|
|
|
|
|
|
@ -188,29 +188,19 @@ from backend.main import app |
|
|
|
$ fastapi dev main.py |
|
|
|
``` |
|
|
|
|
|
|
|
ただし、その場合は毎回`fastapi`コマンドを呼ぶたびに正しいパスを渡すことを覚えておく必要があります。 |
|
|
|
|
|
|
|
さらに、他のツール(たとえば、[VS Code 拡張機能](../editor-support.md)や[FastAPI Cloud](https://fastapicloud.com))が見つけられない場合があります。そのため、`pyproject.toml`の`entrypoint`を使うことを推奨します。 |
|
|
|
|
|
|
|
### アプリをデプロイ(任意) { #deploy-your-app-optional } |
|
|
|
|
|
|
|
任意でFastAPIアプリを[FastAPI Cloud](https://fastapicloud.com)にデプロイできます。まだなら、待機リストに登録してください。 🚀 |
|
|
|
|
|
|
|
すでに**FastAPI Cloud**アカウントがある場合(待機リストから招待済みの場合😉)、1コマンドでアプリケーションをデプロイできます。 |
|
|
|
|
|
|
|
デプロイする前に、ログインしていることを確認してください: |
|
|
|
|
|
|
|
<div class="termy"> |
|
|
|
または、`fastapi dev`コマンドに`--entrypoint`オプションを渡すこともできます: |
|
|
|
|
|
|
|
```console |
|
|
|
$ fastapi login |
|
|
|
|
|
|
|
You are logged in to FastAPI Cloud 🚀 |
|
|
|
$ fastapi dev --entrypoint main:app |
|
|
|
``` |
|
|
|
|
|
|
|
</div> |
|
|
|
ただし、その場合は毎回`fastapi`コマンドを呼ぶたびに正しいパスや`entrypoint`を渡すことを覚えておく必要があります。 |
|
|
|
|
|
|
|
さらに、他のツール(たとえば、[VS Code 拡張機能](../editor-support.md)や[FastAPI Cloud](https://fastapicloud.com))が見つけられない場合があります。そのため、`pyproject.toml`の`entrypoint`を使うことを推奨します。 |
|
|
|
|
|
|
|
その後、アプリをデプロイします: |
|
|
|
### アプリをデプロイ(任意) { #deploy-your-app-optional } |
|
|
|
|
|
|
|
任意でFastAPIアプリを[FastAPI Cloud](https://fastapicloud.com)に1コマンドでデプロイできます。 🚀 |
|
|
|
|
|
|
|
<div class="termy"> |
|
|
|
|
|
|
|
@ -226,6 +216,8 @@ Deploying to FastAPI Cloud... |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
CLIはFastAPIアプリケーションを自動検出してクラウドにデプロイします。ログインしていない場合、認証を完了するためにブラウザが開きます。 |
|
|
|
|
|
|
|
以上です!これで、そのURLでアプリにアクセスできます。 ✨ |
|
|
|
|
|
|
|
## ステップ毎の要約 { #recap-step-by-step } |
|
|
|
@ -269,7 +261,7 @@ https://example.com/items/foo |
|
|
|
/items/foo |
|
|
|
``` |
|
|
|
|
|
|
|
/// info | 情報 |
|
|
|
/// note | 備考 |
|
|
|
|
|
|
|
「パス」は一般に「エンドポイント」または「ルート」とも呼ばれます。 |
|
|
|
|
|
|
|
@ -321,7 +313,7 @@ APIを構築するときは、通常、これらの特定のHTTPメソッドを |
|
|
|
* パス `/` |
|
|
|
* <dfn title="HTTP GET メソッド"><code>get</code> オペレーション</dfn> |
|
|
|
|
|
|
|
/// info | `@decorator` 情報 |
|
|
|
/// note | `@decorator` 情報 |
|
|
|
|
|
|
|
Pythonにおける`@something`シンタックスはデコレータと呼ばれます。 |
|
|
|
|
|
|
|
|