Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 30 of 156 for 404 (0.17 sec)

  1. docs_src/additional_responses/tutorial004.py

    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.responses import FileResponse
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        id: str
        value: str
    
    
    responses = {
        404: {"description": "Item not found"},
        302: {"description": "The item was moved"},
        403: {"description": "Not enough privileges"},
    }
    
    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 701 bytes
    - Viewed (0)
  2. docs/zh/docs/advanced/additional-responses.md

    您可以向路径操作装饰器传递参数 `responses` 。
    
    它接收一个 `dict`,键是每个响应的状态代码(如`200`),值是包含每个响应信息的其他 `dict`。
    
    每个响应字典都可以有一个关键模型,其中包含一个 `Pydantic` 模型,就像 `response_model` 一样。
    
    **FastAPI**将采用该模型,生成其`JSON Schema`并将其包含在`OpenAPI`中的正确位置。
    
    例如,要声明另一个具有状态码 `404` 和`Pydantic`模型 `Message` 的响应,可以写:
    ```Python hl_lines="18  22"
    {!../../../docs_src/additional_responses/tutorial001.py!}
    ```
    
    
    !!! Note
    	请记住,您必须直接返回 `JSONResponse` 。
    
    !!! Info
    	`model` 密钥不是OpenAPI的一部分。
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 15:53:39 GMT 2024
    - 8.2K bytes
    - Viewed (0)
  3. tests/test_tutorial/test_dependencies/test_tutorial008d_an.py

        client = TestClient(app)
        return client
    
    
    def test_get_no_item(client: TestClient):
        response = client.get("/items/foo")
        assert response.status_code == 404, response.text
        assert response.json() == {"detail": "Item not found, there's only a plumbus here"}
    
    
    def test_get(client: TestClient):
        response = client.get("/items/plumbus")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  4. docs_src/app_testing/app_b/main.py

        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item_id not in fake_db:
            raise HTTPException(status_code=404, detail="Item not found")
        return fake_db[item_id]
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item, x_token: str = Header()):
        if x_token != fake_secret_token:
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 14:44:08 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  5. src/main/java/org/codelibs/fess/app/web/thumbnail/ThumbnailAction.java

                // 404
                throw responseManager.new404("Thumbnail for " + form.docId + " is not found.");
            }
    
            final File thumbnailFile = thumbnailManager.getThumbnailFile(doc);
            if (thumbnailFile == null) {
                if (fessConfig.isThumbnailEnabled()) {
                    thumbnailManager.offer(doc);
                }
                // 404
    Java
    - Registered: Mon May 06 08:04:11 GMT 2024
    - Last Modified: Thu Feb 22 01:37:57 GMT 2024
    - 3.6K bytes
    - Viewed (0)
  6. docs/zh/docs/tutorial/handling-errors.md

    需要向客户端返回错误提示的场景主要如下:
    
    - 客户端没有执行操作的权限
    - 客户端没有访问资源的权限
    - 客户端要访问的项目不存在
    - 等等 ...
    
    遇到这些情况时,通常要返回 **4XX**(400 至 499)**HTTP 状态码**。
    
    **4XX** 状态码与表示请求成功的 **2XX**(200 至 299) HTTP 状态码类似。
    
    只不过,**4XX** 状态码表示客户端发生的错误。
    
    大家都知道**「404 Not Found」**错误,还有调侃这个错误的笑话吧?
    
    ## 使用 `HTTPException`
    
    向客户端返回 HTTP 错误响应,可以使用 `HTTPException`。
    
    ### 导入 `HTTPException`
    
    ```Python hl_lines="1"
    {!../../../docs_src/handling_errors/tutorial001.py!}
    
    ```
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 8.4K bytes
    - Viewed (0)
  7. okhttp/src/main/kotlin/okhttp3/Callback.kt

       *
       * Note that transport-layer success (receiving a HTTP response code, headers and body) does not
       * necessarily indicate application-layer success: `response` may still indicate an unhappy HTTP
       * response code like 404 or 500.
       */
      @Throws(IOException::class)
      fun onResponse(
        call: Call,
        response: Response,
      )
    Plain Text
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jan 08 01:13:22 GMT 2024
    - 1.6K bytes
    - Viewed (0)
  8. regression-test/src/androidTest/java/okhttp/regression/IssueReproductionTest.java

        Request request = new Request.Builder()
                .url(url)
                .build();
        try (Response response = client.newCall(request).execute()) {
          assertTrue(response.code() == 200 || response.code() == 404);
          assertEquals(Protocol.HTTP_2, response.protocol());
    
          for (Certificate c: response.handshake().peerCertificates()) {
            X509Certificate x = (X509Certificate) c;
            System.out.println(x.getSubjectDN());
    Java
    - Registered: Fri May 03 11:42:14 GMT 2024
    - Last Modified: Mon Jul 26 06:37:08 GMT 2021
    - 1.9K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_dependencies/test_tutorial008d.py

        client = TestClient(app)
        return client
    
    
    def test_get_no_item(client: TestClient):
        response = client.get("/items/foo")
        assert response.status_code == 404, response.text
        assert response.json() == {"detail": "Item not found, there's only a plumbus here"}
    
    
    def test_get(client: TestClient):
        response = client.get("/items/plumbus")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 1.2K bytes
    - Viewed (0)
  10. docs_src/dependencies/tutorial008d.py

            raise InternalError(
                f"The portal gun is too dangerous to be owned by {username}"
            )
        if item_id != "plumbus":
            raise HTTPException(
                status_code=404, detail="Item not found, there's only a plumbus here"
            )
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 694 bytes
    - Viewed (0)
Back to top