Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 79 for or (0.16 sec)

  1. docs_src/dependencies/tutorial005_py310.py

    def query_extractor(q: str | None = None):
        return q
    
    
    def query_or_cookie_extractor(
        q: str = Depends(query_extractor), last_query: str | None = Cookie(default=None)
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri May 13 23:38:22 GMT 2022
    - 443 bytes
    - Viewed (0)
  2. docs_src/dependencies/tutorial005.py

        return q
    
    
    def query_or_cookie_extractor(
        q: str = Depends(query_extractor),
        last_query: Union[str, None] = Cookie(default=None),
    ):
        if not q:
            return last_query
        return q
    
    
    @app.get("/items/")
    async def read_query(query_or_default: str = Depends(query_or_cookie_extractor)):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 486 bytes
    - Viewed (0)
  3. tests/test_tutorial/test_websockets/test_tutorial002_an_py310.py

                assert data == "Session cookie or query token value is: fakesession"
                data = websocket.receive_text()
                assert data == f"Message text was: {message}, for item ID: foo"
                message = "Message two"
                websocket.send_text(message)
                data = websocket.receive_text()
                assert data == "Session cookie or query token value is: fakesession"
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 3.9K bytes
    - Viewed (0)
  4. docs_src/security/tutorial003_an.py

        if not user_dict:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
        user = UserInDB(**user_dict)
        hashed_password = fake_hash_password(form_data.password)
        if not hashed_password == user.hashed_password:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
    
        return {"access_token": user.username, "token_type": "bearer"}
    
    
    @app.get("/users/me")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  5. docs_src/security/tutorial003_an_py310.py

        if not user_dict:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
        user = UserInDB(**user_dict)
        hashed_password = fake_hash_password(form_data.password)
        if not hashed_password == user.hashed_password:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
    
        return {"access_token": user.username, "token_type": "bearer"}
    
    
    @app.get("/users/me")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 2.5K bytes
    - Viewed (0)
  6. docs_src/security/tutorial003_py310.py

        if not user_dict:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
        user = UserInDB(**user_dict)
        hashed_password = fake_hash_password(form_data.password)
        if not hashed_password == user.hashed_password:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
    
        return {"access_token": user.username, "token_type": "bearer"}
    
    
    @app.get("/users/me")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 2.4K bytes
    - Viewed (0)
  7. docs_src/additional_responses/tutorial002.py

    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
        response_model=Item,
        responses={
            200: {
                "content": {"image/png": {}},
                "description": "Return the JSON item or an image.",
            }
        },
    )
    async def read_item(item_id: str, img: Union[bool, None] = None):
        if img:
            return FileResponse("image.png", media_type="image/png")
        else:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat May 14 11:59:59 GMT 2022
    - 628 bytes
    - Viewed (0)
  8. docs_src/security/tutorial007_an_py39.py

        )
        if not (is_correct_username and is_correct_password):
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
                detail="Incorrect username or password",
                headers={"WWW-Authenticate": "Basic"},
            )
        return credentials.username
    
    
    @app.get("/users/me")
    def read_current_user(username: Annotated[str, Depends(get_current_username)]):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Mar 26 16:56:53 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_security/test_tutorial003_an.py

        assert response.json() == {"detail": "Incorrect username or password"}
    
    
    def test_login_incorrect_username():
        response = client.post("/token", data={"username": "foo", "password": "secret"})
        assert response.status_code == 400, response.text
        assert response.json() == {"detail": "Incorrect username or password"}
    
    
    def test_no_token():
        response = client.get("/users/me")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 8K bytes
    - Viewed (0)
  10. fastapi/applications.py

                    browser to interact with each of them (instead of having multiple
                    browser tabs open). Or if you want to leave fixed the possible URLs.
    
                    If the servers `list` is not provided, or is an empty `list`, the
                    default value would be a `dict` with a `url` value of `/`.
    
                    Each item in the `list` is a `dict` containing:
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top