Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 65 for exists (0.18 sec)

  1. tests/test_param_in_path_and_dependency.py

    from fastapi import Depends, FastAPI
    from fastapi.testclient import TestClient
    
    app = FastAPI()
    
    
    async def user_exists(user_id: int):
        return True
    
    
    @app.get("/users/{user_id}", dependencies=[Depends(user_exists)])
    async def read_users(user_id: int):
        pass
    
    
    client = TestClient(app)
    
    
    def test_read_users():
        response = client.get("/users/42")
        assert response.status_code == 200, response.text
    
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.1K bytes
    - Viewed (0)
  2. docs_src/app_testing/app_b_an_py310/test_main.py

                "title": "The Foo ID Stealers",
                "description": "There goes my stealer",
            },
        )
        assert response.status_code == 400
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  3. docs_src/app_testing/app_b_an_py39/test_main.py

                "title": "The Foo ID Stealers",
                "description": "There goes my stealer",
            },
        )
        assert response.status_code == 400
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  4. docs_src/app_testing/app_b_py310/test_main.py

                "title": "The Foo ID Stealers",
                "description": "There goes my stealer",
            },
        )
        assert response.status_code == 409
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  5. 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 in fake_db:
            raise HTTPException(status_code=409, detail="Item already exists")
        fake_db[item.id] = item
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Tue Jan 09 14:44:08 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  6. docs_src/app_testing/app_b_an/test_main.py

                "title": "The Foo ID Stealers",
                "description": "There goes my stealer",
            },
        )
        assert response.status_code == 400
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  7. docs_src/app_testing/app_b/test_main.py

                "title": "The Foo ID Stealers",
                "description": "There goes my stealer",
            },
        )
        assert response.status_code == 409
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  8. docs/en/docs/tutorial/security/simple-oauth2.md

    Both of these dependencies will just return an HTTP error if the user doesn't exist, or if is inactive.
    
    So, in our endpoint, we will only get a user if the user exists, was correctly authenticated, and is active:
    
    === "Python 3.10+"
    
        ```Python hl_lines="58-66  69-74  94"
        {!> ../../../docs_src/security/tutorial003_an_py310.py!}
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 12.5K bytes
    - Viewed (0)
  9. docs/en/docs/python-types.md

    These types that have internal types are called "**generic**" types. And it's possible to declare them, even with their internal types.
    
    To declare those types and the internal types, you can use the standard Python module `typing`. It exists specifically to support these type hints.
    
    #### Newer versions of Python
    
    The syntax using `typing` is **compatible** with all versions, from Python 3.6 to the latest ones, including Python 3.9, Python 3.10, etc.
    
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 17K bytes
    - Viewed (0)
  10. docs/en/docs/tutorial/security/first-steps.md

    If it doesn't see an `Authorization` header, or the value doesn't have a `Bearer ` token, it will respond with a 401 status code error (`UNAUTHORIZED`) directly.
    
    You don't even have to check if the token exists to return an error. You can be sure that if your function is executed, it will have a `str` in that token.
    
    You can try it already in the interactive docs:
    
    <img src="/img/tutorial/security/image03.png">
    
    Plain Text
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 8.9K bytes
    - Viewed (0)
Back to top