Search Options

Results per page
Sort
Preferred Languages
Advance

Results 61 - 70 of 120 for HTTPException (0.85 sec)

  1. docs_src/handling_errors/tutorial001_py39.py

    from fastapi import FastAPI, HTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str):
        if item_id not in items:
            raise HTTPException(status_code=404, detail="Item not found")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 299 bytes
    - Viewed (0)
  2. docs_src/handling_errors/tutorial002_py39.py

    from fastapi import FastAPI, HTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items-header/{item_id}")
    async def read_item_header(item_id: str):
        if item_id not in items:
            raise HTTPException(
                status_code=404,
                detail="Item not found",
                headers={"X-Error": "There goes my error"},
            )
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 404 bytes
    - Viewed (0)
  3. docs_src/security/tutorial005_py310.py

    ):
        if current_user.disabled:
            raise HTTPException(status_code=400, detail="Inactive user")
        return current_user
    
    
    @app.post("/token")
    async def login_for_access_token(
        form_data: OAuth2PasswordRequestForm = Depends(),
    ) -> Token:
        user = authenticate_user(fake_users_db, form_data.username, form_data.password)
        if not user:
            raise HTTPException(status_code=400, detail="Incorrect username or password")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Sep 29 02:57:38 UTC 2025
    - 5.2K bytes
    - Viewed (0)
  4. docs_src/dependencies/tutorial008c_an_py39.py

    from typing import Annotated
    
    from fastapi import Depends, FastAPI, HTTPException
    
    app = FastAPI()
    
    
    class InternalError(Exception):
        pass
    
    
    def get_username():
        try:
            yield "Rick"
        except InternalError:
            print("Oops, we didn't raise again, Britney ๐Ÿ˜ฑ")
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
        if item_id == "portal-gun":
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Feb 24 23:06:37 UTC 2024
    - 700 bytes
    - Viewed (0)
  5. docs_src/sql_databases/tutorial001_an_py39.py

        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.delete("/heroes/{hero_id}")
    def delete_hero(hero_id: int, session: SessionDep):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        session.delete(hero)
        session.commit()
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  6. docs/ja/docs/tutorial/dependencies/dependencies-with-yield.md

    **FastAPI** ใฏใ“ใ‚Œใ‚’ๅฎŸ็พใ™ใ‚‹ใŸใ‚ใซๅ†…้ƒจ็š„ใซไฝฟ็”จใ—ใฆใ„ใพใ™ใ€‚
    
    ///
    
    ## `yield`ใจ`HTTPException`ใ‚’ๆŒใคไพๅญ˜้–ขไฟ‚
    
    `yield`ใจไพ‹ๅค–ใ‚’ใ‚ญใƒฃใƒƒใƒใ™ใ‚‹`try`ใƒ–ใƒญใƒƒใ‚ฏใ‚’ๆŒใคใ“ใจใŒใงใใ‚‹ไพๅญ˜้–ขไฟ‚ใ‚’ไฝฟ็”จใ™ใ‚‹ใ“ใจใŒใงใใ‚‹ใ“ใจใŒใ‚ใ‹ใ‚Šใพใ—ใŸใ€‚
    
    `yield`ใฎๅพŒใฎ็ต‚ไบ†ใ‚ณใƒผใƒ‰ใง`HTTPException`ใชใฉใ‚’็™บ็”Ÿใ•ใ›ใŸใใชใ‚‹ใ‹ใ‚‚ใ—ใ‚Œใพใ›ใ‚“ใ€‚ใ—ใ‹ใ—**ใใ‚Œใฏใ†ใพใใ„ใใพใ›ใ‚“**
    
    `yield`ใ‚’ๆŒใคไพๅญ˜้–ขไฟ‚ใฎ็ต‚ไบ†ใ‚ณใƒผใƒ‰ใฏ[ไพ‹ๅค–ใƒใƒณใƒ‰ใƒฉ](../handling-errors.md#_4){.internal-link target=_blank}ใฎ*ๅพŒใซ*ๅฎŸ่กŒใ•ใ‚Œใพใ™ใ€‚ไพๅญ˜้–ขไฟ‚ใซใ‚ˆใฃใฆๆŠ•ใ’ใ‚‰ใ‚ŒใŸไพ‹ๅค–ใ‚’็ต‚ไบ†ใ‚ณใƒผใƒ‰๏ผˆ`yield`ใฎๅพŒ๏ผ‰ใงใ‚ญใƒฃใƒƒใƒใ™ใ‚‹ใ‚‚ใฎใฏใชใซใ‚‚ใ‚ใ‚Šใพใ›ใ‚“ใ€‚
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 18 02:25:44 UTC 2024
    - 12.3K bytes
    - Viewed (0)
  7. docs_src/security/tutorial004_py310.py

        if current_user.disabled:
            raise HTTPException(status_code=400, detail="Inactive user")
        return current_user
    
    
    @app.post("/token")
    async def login_for_access_token(
        form_data: OAuth2PasswordRequestForm = Depends(),
    ) -> Token:
        user = authenticate_user(fake_users_db, form_data.username, form_data.password)
        if not user:
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Sep 29 02:57:38 UTC 2025
    - 4K bytes
    - Viewed (0)
  8. docs_src/security/tutorial004_py39.py

        if current_user.disabled:
            raise HTTPException(status_code=400, detail="Inactive user")
        return current_user
    
    
    @app.post("/token")
    async def login_for_access_token(
        form_data: OAuth2PasswordRequestForm = Depends(),
    ) -> Token:
        user = authenticate_user(fake_users_db, form_data.username, form_data.password)
        if not user:
            raise HTTPException(
                status_code=status.HTTP_401_UNAUTHORIZED,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 4.1K bytes
    - Viewed (0)
  9. docs_src/sql_databases/tutorial001_py310.py

        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        return hero
    
    
    @app.delete("/heroes/{hero_id}")
    def delete_hero(hero_id: int, session: Session = Depends(get_session)):
        hero = session.get(Hero, hero_id)
        if not hero:
            raise HTTPException(status_code=404, detail="Hero not found")
        session.delete(hero)
        session.commit()
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Oct 09 19:44:42 UTC 2024
    - 1.7K bytes
    - Viewed (0)
  10. tests/test_dependency_after_yield_raise.py

    from typing import Annotated, Any
    
    import pytest
    from fastapi import Depends, FastAPI, HTTPException
    from fastapi.testclient import TestClient
    
    
    class CustomError(Exception):
        pass
    
    
    def catching_dep() -> Any:
        try:
            yield "s"
        except CustomError as err:
            raise HTTPException(status_code=418, detail="Session error") from err
    
    
    def broken_dep() -> Any:
        yield "s"
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 1.7K bytes
    - Viewed (0)
Back to top