Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 61 - 70 of 502 for tutorial001_an_py310 (0.12 seconds)

  1. docs/zh-hant/docs/tutorial/security/first-steps.md

    但不必通讀整份冗長規格只為了找出你需要的幾個重點。
    
    就用 FastAPI 提供的工具處理安全性。
    
    ## 看起來如何 { #how-it-looks }
    
    先直接跑範例看效果,再回頭理解其原理。
    
    ## 建立 `main.py` { #create-main-py }
    
    將範例複製到檔案 `main.py`:
    
    {* ../../docs_src/security/tutorial001_an_py310.py *}
    
    ## 執行 { #run-it }
    
    /// info
    
    當你使用 `pip install "fastapi[standard]"` 指令安裝時,[`python-multipart`](https://github.com/Kludex/python-multipart) 套件會隨 FastAPI 自動安裝。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 7.2K bytes
    - Click Count (0)
  2. docs/zh/docs/tutorial/security/first-steps.md

    但为了节省你的时间,不必为获取少量信息而通读冗长的规范。
    
    我们直接使用 **FastAPI** 提供的安全工具。
    
    ## 效果预览 { #how-it-looks }
    
    先直接运行代码看看效果,之后再回过头理解其背后的原理。
    
    ## 创建 `main.py` { #create-main-py }
    
    把下面的示例代码复制到 `main.py`:
    
    {* ../../docs_src/security/tutorial001_an_py310.py *}
    
    ## 运行 { #run-it }
    
    /// info | 信息
    
    当你使用命令 `pip install "fastapi[standard]"` 安装 **FastAPI** 时,[`python-multipart`](https://github.com/Kludex/python-multipart) 包会自动安装。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 7.5K bytes
    - Click Count (0)
  3. docs/en/docs/how-to/custom-request-and-route.md

    {* ../../docs_src/custom_request_and_route/tutorial002_an_py310.py hl[14,16] *}
    
    If an exception occurs, the`Request` instance will still be in scope, so we can read and make use of the request body when handling the error:
    
    {* ../../docs_src/custom_request_and_route/tutorial002_an_py310.py hl[17:19] *}
    
    ## Custom `APIRoute` class in a router { #custom-apiroute-class-in-a-router }
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 4.4K bytes
    - Click Count (0)
  4. docs/zh-hant/docs/tutorial/dependencies/classes-as-dependencies.md

    接著,我們可以把上面的相依項(dependable)`common_parameters` 改成類別 `CommonQueryParams`:
    
    {* ../../docs_src/dependencies/tutorial002_an_py310.py hl[11:15] *}
    
    注意用來建立該類別實例的 `__init__` 方法:
    
    {* ../../docs_src/dependencies/tutorial002_an_py310.py hl[12] *}
    
    ...它的參數與我們之前的 `common_parameters` 相同:
    
    {* ../../docs_src/dependencies/tutorial001_an_py310.py hl[8] *}
    
    **FastAPI** 會用這些參數來「解析」該相依性。
    
    兩種情況下都會有:
    
    - 一個可選的查詢參數 `q`,型別為 `str`。
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Feb 14 08:15:26 GMT 2026
    - 6.7K bytes
    - Click Count (0)
  5. docs/ko/docs/how-to/authentication-error-status-code.md

    예를 들어, 기본값인 `401 Unauthorized` 오류 대신 `403 Forbidden` 오류를 반환하는 `HTTPBearer`의 서브클래스를 만들 수 있습니다:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    /// tip | 팁
    
    함수는 예외를 `return`하는 것이지 `raise`하지 않는다는 점에 유의하세요. 예외를 발생시키는(`raise`) 작업은 내부 코드의 나머지 부분에서 수행됩니다.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 14:06:26 GMT 2026
    - 1.3K bytes
    - Click Count (0)
  6. docs/en/docs/tutorial/dependencies/index.md

    ### Import `Depends` { #import-depends }
    
    {* ../../docs_src/dependencies/tutorial001_an_py310.py hl[3] *}
    
    ### Declare the dependency, in the "dependant" { #declare-the-dependency-in-the-dependant }
    
    The same way you use `Body`, `Query`, etc. with your *path operation function* parameters, use `Depends` with a new parameter:
    
    {* ../../docs_src/dependencies/tutorial001_an_py310.py hl[13,18] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 9.5K bytes
    - Click Count (0)
  7. docs/en/docs/how-to/authentication-error-status-code.md

    For example, you can create a subclass of `HTTPBearer` that returns a `403 Forbidden` error instead of the default `401 Unauthorized` error:
    
    {* ../../docs_src/authentication_error_status_code/tutorial001_an_py310.py hl[9:13] *}
    
    /// tip
    
    Notice that the function returns the exception instance, it doesn't raise it. The raising is done in the rest of the internal code.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 1.2K bytes
    - Click Count (0)
  8. docs/ja/docs/how-to/authentication-error-status-code.md

    たとえば、既定の `401 Unauthorized` エラーの代わりに `403 Forbidden` エラーを返す `HTTPBearer` のサブクラスを作成できます:
    
    {* ../../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 14:07:17 GMT 2026
    - 1.4K bytes
    - Click Count (0)
  9. docs/zh/docs/tutorial/path-params-numeric-validations.md

    {* ../../docs_src/path_params_numeric_validations/tutorial003_an_py310.py hl[10] *}
    
    ## 数值校验:大于等于 { #number-validations-greater-than-or-equal }
    
    使用 `Query` 和 `Path`(以及你稍后会看到的其他类)你可以声明数值约束。
    
    在这里,使用 `ge=1` 后,`item_id` 必须是一个整数,值要「`g`reater than or `e`qual」1。
    
    {* ../../docs_src/path_params_numeric_validations/tutorial004_an_py310.py hl[10] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:06:37 GMT 2026
    - 6K bytes
    - Click Count (0)
  10. 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)
Back to Top