Results of 1 - 10 of about 16 for init (0.003 sec.)
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. 12615
- Custom Response Classes - File, HTML, Redirect, Streaming, etc. There are several custom response classes you can use to create an instance and return them directly from your path operations . Read more about it in the FastAPI docs for Cust
...esponses.UJSONResponse options: members: - charset - status_code - media_type - body - background - raw_headers - render - init_headers - headers - set_cookie - delete_cookie ::: fastapi.responses.ORJSONResponse options: members: - charset - status_c...ode - media_type - body - background - raw_headers - render - init_headers - headers - set_cookie - delete_cookie Starlette Responses ::: fastapi.responses.FileResponse options: members: -...chunk_size - charset - status_code - media_type - body - background - raw_headers - render - init_headers - headers - set_cookie - delete_cookie ::: fastapi.responses.HTMLResponse options: members: - charset - status_cod... - https://man.mtool.work/fastapi/0.115/reference/responses/
- 依存関係としてのクラス 11852
- 依存関係としてのクラス 依存性注入 システムを深く掘り下げる前に、先ほどの例をアップグレードしてみましょう。 前の例の dict 前の例では、依存関係("dependable")から dict を返していました: Python 3.8+ - non-Annotated from typing import Union fr
...ス Pythonのクラスのインスタンスを作成する際に、同じ構文を使用していることに気づくかもしれません。 例えば: class Cat : def __init__ ( self , name : str ): self . name = name fluffy = Cat ( name = "Mr Fluffy" ) この場合、 fluffy は Cat クラスのインスタン...ake_items_db = [{ "item_name" : "Foo" }, { "item_name" : "Bar" }, { "item_name" : "Baz" }] class CommonQueryParams : def __init__ ( self , q : Union [ str , None ] = None , skip : int = 0 , limit : int = 100 ): self . q = q self . skip = skip self ....ake_items_db = [{ "item_name" : "Foo" }, { "item_name" : "Bar" }, { "item_name" : "Baz" }] class CommonQueryParams : def __init__ ( self , q : str | None = None , skip : int = 0 , limit : int = 100 ): self . q = q self . skip = skip self . limit = li... - https://man.mtool.work/fastapi/0.115/tutorial/dependencies/classes-as-dependenci...
- Advanced Dependencies 11800
- Advanced Dependencies Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . Parameterized dependencies All the dependencies we have seen are a fixed function or class. B
...from typing import Annotated from fastapi import Depends , FastAPI app = FastAPI () class FixedContentQueryChecker : def __init__ ( self , fixed_content : str ): self . fixed_content = fixed_content def __call__ ( self , q : str = "" ): if q : return...i import Depends , FastAPI from typing_extensions import Annotated app = FastAPI () class FixedContentQueryChecker : def __init__ ( self , fixed_content : str ): self . fixed_content = fixed_content def __call__ ( self , q : str = "" ): if q : return...notated version if possible. from fastapi import Depends , FastAPI app = FastAPI () class FixedContentQueryChecker : def __init__ ( self , fixed_content : str ): self . fixed_content = fixed_content def __call__ ( self , q : str = "" ): if q : return... - https://man.mtool.work/fastapi/0.115/advanced/advanced-dependencies/
- Bigger Applications - Multiple Files 9686
- 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
...uivalent of Flask's Blueprints. An example file structure Let's say you have a file structure like this: . ├── app │ ├── __init__.py │ ├── main.py │ ├── dependencies.py │ └── routers │ │ ├── __init__.py │ │ ├── items.py │ │ └── users.py │ └── interna...l │ ├── __init__.py │ └── admin.py Tip There are several __init__.py files: one in each directory or subdirectory. This is what allows im...ould have a line like: from app.routers import items The app directory contains everything. And it has an empty file app/__init__.py , so it is a "Python package" (a collection of "Python modules"): app . It contains an app/main.py file. As it is ins... - https://man.mtool.work/fastapi/0.115/tutorial/bigger-applications/
- Configure Swagger UI 8161
- Configure Swagger UI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . You can configure some extra Swagger UI parameters . To configure them, pass the swagger_ui_pa
...[ Optional [ str ], Doc ( """ The OAuth2 redirect URL, it is normally automatically handled by FastAPI. """ ), ] = None , init_oauth : Annotated [ Optional [ Dict [ str , Any ]], Doc ( """ A dictionary with Swagger UI OAuth2 initialization configura...irect_url } '," html += """ presets: [ SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset ], })""" if init_oauth : html += f """ ui.initOAuth( { json . dumps ( jsonable_encoder ( init_oauth )) } ) """ html += """ </script> </body...} </title> <!-- needed for adaptive design --> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"> """ if with_google_fonts : html += """ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400... - https://man.mtool.work/fastapi/0.115/how-to/configure-swagger-ui/
- Custom Docs UI Static Assets (Self-Hosting) 8057
- Custom Docs UI Static Assets (Self-Hosting) Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . The API docs use Swagger UI and ReDoc , and each of those need some Jav
...gure the docs to use them. Project file structure Let's say your project file structure looks like this: . ├── app │ ├── __init__.py │ ├── main.py Now create a directory to store those static files. Your new file structure could look like this: . ├──...app │ ├── __init__.py │ ├── main.py └── static/ Download the files Download the static files needed for the docs and put them on that stati...ger-ui.css And ReDoc uses the file: redoc.standalone.js After that, your file structure could look like: . ├── app │ ├── __init__.py │ ├── main.py └── static ├── redoc.standalone.js ├── swagger-ui-bundle.js └── swagger-ui.css Serve the static files I... - https://man.mtool.work/fastapi/0.115/how-to/custom-docs-ui-assets/
- Async Tests 7763
- 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,
...ample, let's consider a file structure similar to the one described in Bigger Applications and Testing : . ├── app │ ├── __init__.py │ ├── main.py │ └── test_main.py The file main.py would have: Python 3.8+ from fastapi import FastAPI app = FastAPI (... - https://man.mtool.work/fastapi/0.115/advanced/async-tests/
- FastAPI CLI 7763
- FastAPI CLI Warning The current page still doesn't have a translation for this language. But you can help translating it: Contributing . FastAPI CLI is a command line program that you can use to serve your FastAPI app, manage your FastAPI p
...t></span> Starting development server ? Searching for package file structure from directories with <font color="#3465A4">__init__.py</font> files Importing from <font color="#75507B">/home/user/code/</font><font color="#AD7FA8">awesomeapp</font> <spa...nternally, FastAPI CLI uses Uvicorn , a high-performance, production-ready, ASGI server. ? fastapi dev Running fastapi dev initiates development mode. By default, auto-reload is enabled, automatically reloading the server when you make changes to you... - https://man.mtool.work/fastapi/0.115/fastapi-cli/
- Pythonの型の紹介 7763
- Pythonの型の紹介 Python 3.6以降 では「型ヒント」オプションがサポートされています。 これらの "型ヒント" は変数の 型 を宣言することができる新しい構文です。(Python 3.6以降) 変数に型を宣言することでエディターやツールがより良いサポートを提供す
...ンポートします(大文字の L を含む): Python 3.8+ from typing import List def process_items ( items : List [ str ]): for item in items : print ( item ) ? Other versions and variants Python 3.9+ def process_items ( items : list [ str ]): for item in item...ので、それらを角括弧で囲んでいます。 Python 3.8+ from typing import List def process_items ( items : List [ str ]): for item in items : print ( item ) ? Other versions and variants Python 3.9+ def process_items ( items : list [ str ]): for item in item...ラスを宣言することもできます。 例えば、 Person クラスという名前のクラスがあるとしましょう: Python 3.8+ class Person : def __init__ ( self , name : str ): self . name = name def get_person_name ( one_person : Person ): return one_person . name 変数の型... - https://man.mtool.work/fastapi/0.115/python-types/
- WebSocket 7693
- WebSocket FastAPI で WebSocket が使用できます。 WebSockets のインストール まず WebSockets のインストールが必要です。 $ pip install websockets ---> 100% WebSocket クライアント 本番環境 本番環境では、React、Vue.js、Angularなどの最新のフレーム
....send(input.value) input.value = '' event.preventDefault() } </script> </body> </html> """ class ConnectionManager : def __init__ ( self ): self . active_connections : List [ WebSocket ] = [] async def connect ( self , websocket : WebSocket ): await....send(input.value) input.value = '' event.preventDefault() } </script> </body> </html> """ class ConnectionManager : def __init__ ( self ): self . active_connections : list [ WebSocket ] = [] async def connect ( self , websocket : WebSocket ): await... - https://man.mtool.work/fastapi/0.115/advanced/websockets/