Results of 1 - 10 of about 10 for root (0.002 sec.)
- Behind a Proxy 14069
- Behind a Proxy Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration
...that adds an extra path prefix that is not seen by your application. In these cases you can use root_path to configure your application. The root_path is a mechanism provided by the ASGI specification (that FastAPI is built...on, through Starlette). The root_path is used to handle these specific cases. And it's also used internally when mounting sub-applications. Proxy with a st...Request app = FastAPI () @app . get ( "/app" ) def read_main ( request : Request ): return { "message" : "Hello World" , "root_path" : request . scope . get ( "root_path" )} And the proxy would be "stripping" the path prefix on the fly before transm... - https://man.mtool.work/fastapi/0.115/advanced/behind-a-proxy/
- 最初のステップ 9242
- 最初のステップ 最もシンプルなFastAPIファイルは以下のようになります: Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def root (): return { "message" : "Hello World" } これを main.py にコピーします。 ライブサ
...毎の要約 Step 1: FastAPI をインポート Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def root (): return { "message" : "Hello World" } FastAPI は、APIのすべての機能を提供するPythonクラスです。 技術詳細 FastAPI は Sta...2: FastAPI の「インスタンス」を生成 Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def root (): return { "message" : "Hello World" } ここで、 app 変数が FastAPI クラスの「インスタンス」になります。 これが、すべての...を作成したとき: Python 3.8+ from fastapi import FastAPI my_awesome_api = FastAPI () @my_awesome_api . get ( "/" ) async def root (): return { "message" : "Hello World" } そして、それを main.py ファイルに置き、次のように uvicorn を呼び出します: $ uvico... - https://man.mtool.work/fastapi/0.115/tutorial/first-steps/
- Sub Applications - Mounts 9010
- Sub Applications - Mounts Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you need to have two independent FastAPI applications, with their own independent Open
...es, they will work correctly, because the browser will be able to talk to each specific app or sub-app. Technical Details: root_path When you mount a sub-application as described above, FastAPI will take care of communicating the mount path for the s...ub-application using a mechanism from the ASGI specification called a root_path . That way, the sub-application will know to use that path prefix for the docs UI. And the sub-application could also...have its own mounted sub-applications and everything would work correctly, because FastAPI handles all these root_path s automatically. You will learn more about the root_path and how to use it explicitly in the section about Behind a P... - https://man.mtool.work/fastapi/0.115/advanced/sub-applications/
- Async Tests 8885
- Async Tests Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You have already seen how to test your FastAPI applications using the provided TestClient . Up to now,
...main.py The file main.py would have: Python 3.8+ from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def root (): return { "message" : "Tomato" } The file test_main.py would have the tests for main.py , it could look like this now:...8+ import pytest from httpx import ASGITransport , AsyncClient from .main import app @pytest . mark . anyio async def test_root (): async with AsyncClient ( transport = ASGITransport ( app = app ), base_url = "http://test" ) as ac : response = await...8+ import pytest from httpx import ASGITransport , AsyncClient from .main import app @pytest . mark . anyio async def test_root (): async with AsyncClient ( transport = ASGITransport ( app = app ), base_url = "http://test" ) as ac : response = await... - https://man.mtool.work/fastapi/0.115/advanced/async-tests/
- Bigger Applications - Multiple Files 8438
- Bigger Applications - Multiple Files Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . If you are building an application or a web API, it's rarely the case that you
...= [ Depends ( get_token_header )], responses = { 418 : { "description" : "I'm a teapot" }}, ) @app . get ( "/" ) async def root (): return { "message" : "Hello Bigger Applications!" } Import the APIRouter Now we import the other submodules that have...= [ Depends ( get_token_header )], responses = { 418 : { "description" : "I'm a teapot" }}, ) @app . get ( "/" ) async def root (): return { "message" : "Hello Bigger Applications!" } As the files app/routers/users.py and app/routers/items.py are sub...= [ Depends ( get_token_header )], responses = { 418 : { "description" : "I'm a teapot" }}, ) @app . get ( "/" ) async def root (): return { "message" : "Hello Bigger Applications!" } Include the APIRouter s for users and items Now, let's include the... - https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
- FastAPI 8080
- FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production ドキュメント : https://fastapi.tiangolo.com ソースコード : https://github.com/fastapi/fastapi FastAPI は、Pythonの標準である型ヒントに基づいてPyt
...の作成 main.py を作成し、以下のコードを入力します: from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) def read_root (): return { "Hello" : "World" } @app . get ( "/items/ {item_id} " ) def read_item ( item_id : int , q : str = None ): ret...it を使用するときは、 async def を使います: from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) async def read_root (): return { "Hello" : "World" } @app . get ( "/items/ {item_id} " ) async def read_item ( item_id : int , q : str = None...del app = FastAPI () class Item ( BaseModel ): name : str price : float is_offer : bool = None @app . get ( "/" ) def read_root (): return { "Hello" : "World" } @app . get ( "/items/ {item_id} " ) def read_item ( item_id : int , q : str = None ): ret... - https://man.mtool.work/fastapi/0.115/
- Using the Request Directly 8027
- Using the Request Directly Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Up to now, you have been declaring the parts of the request that you need with their typ
...directly. Python 3.8+ from fastapi import FastAPI , Request app = FastAPI () @app . get ( "/items/ {item_id} " ) def read_root ( item_id : str , request : Request ): client_host = request . client . host return { "client_host" : client_host , "item_... - https://man.mtool.work/fastapi/0.115/advanced/using-request-directly/
- 条件付き OpenAPI 7919
- 条件付き OpenAPI 必要であれば、設定と環境変数を利用して、環境に応じて条件付きでOpenAPIを構成することが可能です。また、完全にOpenAPIを無効にすることもできます。 セキュリティとAPI、およびドキュメントについて 本番環境においてドキュメントのUIを
...str = "/openapi.json" settings = Settings () app = FastAPI ( openapi_url = settings . openapi_url ) @app . get ( "/" ) def root (): return { "message" : "Hello World" } ここでは openapi_url の設定を、デフォルトの "/openapi.json" のまま宣言しています。... - https://man.mtool.work/fastapi/0.115/how-to/conditional-openapi/
- デバッグ 7919
- デバッグ Visual Studio CodeやPyCharmなどを使用して、エディター上でデバッガーと連携できます。 uvicorn の実行 FastAPIアプリケーション上で、 uvicorn を直接インポートして実行します: Python 3.8+ import uvicorn from fastapi import FastAPI app = F
...astAPI () @app . get ( "/" ) def root (): a = "a" b = "b" + a return { "hello world" : b } if __name__ == "__main__" : uvicorn . run ( app , host = "0.0.0.0" ,... - https://man.mtool.work/fastapi/0.115/tutorial/debugging/
- コンテナ内のFastAPI - Docker 7705
- コンテナ内のFastAPI - Docker FastAPIアプリケーションをデプロイする場合、一般的なアプローチは Linuxコンテナ・イメージ をビルドすることです。 基本的には Docker を用いて行われます。生成されたコンテナ・イメージは、いくつかの方法のいずれかでデプ
...py ファイルを作成します: from typing import Union from fastapi import FastAPI app = FastAPI () @app . get ( "/" ) def read_root (): return { "Hello" : "World" } @app . get ( "/items/ {item_id} " ) def read_item ( item_id : int , q : Union [ str , Non... - https://man.mtool.work/fastapi/0.115/deployment/docker/
PREV
1
NEXT