Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1151 - 1160 of 2,110 for py$ (0.23 seconds)

  1. docs/ja/docs/tutorial/debugging.md

    ファイルの名前が `myapp.py` だとします。
    
    以下の様に実行する場合:
    
    <div class="termy">
    
    ```console
    $ python myapp.py
    ```
    
    </div>
    
    Pythonによって自動的に作成されたファイル内の内部変数 `__name__` は、値として文字列 `"__main__"` を持ちます。
    
    なので、以下:
    
    ```Python
        uvicorn.run(app, host="0.0.0.0", port=8000)
    ```
    
    は実行されます。
    
    ---
    
    そのモジュール (ファイル) をインポートした場合は、こうはなりません。
    
    したがって、次のようなもう一つのファイル `importer.py` がある場合:
    
    ```Python
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 3.1K bytes
    - Click Count (0)
  2. docs/zh/docs/how-to/authentication-error-status-code.md

    但如果由于某些原因你的客户端依赖旧行为,你可以在你的安全类中重写方法 `make_not_authenticated_error` 来回退到旧行为。
    
    例如,你可以创建一个 `HTTPBearer` 的子类,使其返回 `403 Forbidden` 错误,而不是默认的 `401 Unauthorized` 错误:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    /// tip | 提示
    
    注意该函数返回的是异常实例,而不是直接抛出它。抛出操作由其余的内部代码完成。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  3. docs/ja/docs/advanced/behind-a-proxy.md

    各リクエストでアプリケーションが使用している現在の `root_path` は取得できます。これは(ASGI 仕様の一部である)`scope` 辞書に含まれます。
    
    ここではデモのため、メッセージに含めています。
    
    {* ../../docs_src/behind_a_proxy/tutorial001_py310.py hl[8] *}
    
    そのうえで、次のように Uvicorn を起動すると:
    
    <div class="termy">
    
    ```console
    $ fastapi run main.py --forwarded-allow-ips="*" --root-path /api/v1
    
    <span style="color: green;">INFO</span>:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
    ```
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 18.9K bytes
    - Click Count (0)
  4. docs/ja/docs/advanced/settings.md

    たとえば、`config.py` というファイルに次のように書けます:
    
    {* ../../docs_src/settings/app01_py310/config.py *}
    
    そして、`main.py` というファイルでそれを使います:
    
    {* ../../docs_src/settings/app01_py310/main.py hl[3,11:13] *}
    
    /// tip | 豆知識
    
    [大規模アプリケーション - 複数ファイル](../tutorial/bigger-applications.md) で見たように、`__init__.py` ファイルも必要です。
    
    ///
    
    ## 依存関係での設定 { #settings-in-a-dependency }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:07:17 GMT 2026
    - 12.7K bytes
    - Click Count (0)
  5. docs/zh-hant/docs/tutorial/encoder.md

    同樣地,這個資料庫不會接受 Pydantic 模型(帶有屬性的物件),只接受 `dict`。
    
    你可以使用 `jsonable_encoder` 來處理。
    
    它接收一個物件(例如 Pydantic 模型),並回傳一個與 JSON 相容的版本:
    
    {* ../../docs_src/encoder/tutorial001_py310.py hl[4,21] *}
    
    在此範例中,它會把 Pydantic 模型轉成 `dict`,並將 `datetime` 轉成 `str`。
    
    呼叫後的結果可以用 Python 標準的 [`json.dumps()`](https://docs.python.org/3/library/json.html#json.dumps) 進行編碼。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  6. docs/en/docs/advanced/wsgi.md

    ///
    
    You need to import `WSGIMiddleware` from `a2wsgi`.
    
    Then wrap the WSGI (e.g. Flask) app with the middleware.
    
    And then mount that under a path.
    
    {* ../../docs_src/wsgi/tutorial001_py310.py hl[1,3,23] *}
    
    /// note
    
    Previously, it was recommended to use `WSGIMiddleware` from `fastapi.middleware.wsgi`, but it is now deprecated.
    
    It’s advised to use the `a2wsgi` package instead. The usage remains the same.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 1.4K bytes
    - Click Count (0)
  7. docs/en/docs/advanced/additional-status-codes.md

    To achieve that, import `JSONResponse`, and return your content there directly, setting the `status_code` that you want:
    
    {* ../../docs_src/additional_status_codes/tutorial001_an_py310.py hl[4,25] *}
    
    /// warning
    
    When you return a `Response` directly, like in the example above, it will be returned directly.
    
    It won't be serialized with a model, etc.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 2K bytes
    - Click Count (0)
  8. docs/zh/docs/tutorial/encoder.md

    同样,这个数据库也不会接收Pydantic模型(带有属性的对象),而只接收`dict`。
    
    对此你可以使用`jsonable_encoder`。
    
    它接收一个对象,比如Pydantic模型,并会返回一个JSON兼容的版本:
    
    {* ../../docs_src/encoder/tutorial001_py310.py hl[4,21] *}
    
    在这个例子中,它将Pydantic模型转换为`dict`,并将`datetime`转换为`str`。
    
    调用它的结果后就可以使用Python标准编码中的[`json.dumps()`](https://docs.python.org/3/library/json.html#json.dumps)。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 1.5K bytes
    - Click Count (0)
  9. docs/zh-hant/docs/advanced/wsgi.md

    /// info
    
    這需要先安裝 `a2wsgi`,例如使用 `pip install a2wsgi`。
    
    ///
    
    你需要從 `a2wsgi` 匯入 `WSGIMiddleware`。
    
    然後用該 middleware 包住 WSGI(例如 Flask)應用。
    
    接著把它掛載到某個路徑下。
    
    {* ../../docs_src/wsgi/tutorial001_py310.py hl[1,3,23] *}
    
    /// note
    
    先前建議使用來自 `fastapi.middleware.wsgi` 的 `WSGIMiddleware`,但現在已棄用。
    
    建議改用 `a2wsgi` 套件。用法保持相同。
    
    只要確保已安裝 `a2wsgi`,並從 `a2wsgi` 正確匯入 `WSGIMiddleware` 即可。
    
    ///
    
    ## 試試看 { #check-it }
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 1.4K bytes
    - Click Count (0)
  10. docs/zh/docs/advanced/wsgi.md

    /// info | 信息
    
    需要安装 `a2wsgi`,例如使用 `pip install a2wsgi`。
    
    ///
    
    您需要从 `a2wsgi` 导入 `WSGIMiddleware`。
    
    然后使用该中间件包装 WSGI 应用(例如 Flask)。
    
    之后将其挂载到某一个路径下。
    
    {* ../../docs_src/wsgi/tutorial001_py310.py hl[1,3,23] *}
    
    /// note | 注意
    
    之前推荐使用 `fastapi.middleware.wsgi` 中的 `WSGIMiddleware`,但它现在已被弃用。
    
    建议改用 `a2wsgi` 包,使用方式保持不变。
    
    只要确保已安装 `a2wsgi` 包,并且从 `a2wsgi` 正确导入 `WSGIMiddleware` 即可。
    
    ///
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 1.4K bytes
    - Click Count (0)
Back to Top