Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 15 for WebSocketException (0.24 sec)

  1. docs/de/docs/reference/exceptions.md

    Sie können Folgendes verwenden:
    
    * `HTTPException`
    * `WebSocketException`
    
    Diese Exceptions können direkt von `fastapi` importiert werden:
    
    ```python
    from fastapi import HTTPException, WebSocketException
    ```
    
    ::: fastapi.HTTPException
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 30 18:16:53 GMT 2024
    - 797 bytes
    - Viewed (0)
  2. docs_src/websockets/tutorial002_py310.py

    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
            <form action="" onsubmit="sendMessage(event)">
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.7K bytes
    - Viewed (0)
  3. docs/en/docs/reference/exceptions.md

    # Exceptions - `HTTPException` and `WebSocketException`
    
    These are the exceptions that you can raise to show errors to the client.
    
    When you raise an exception, as would happen with normal Python, the rest of the execution is aborted. This way you can raise these exceptions from anywhere in the code to abort a request and show the error to the client.
    
    You can use:
    
    * `HTTPException`
    * `WebSocketException`
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 597 bytes
    - Viewed (0)
  4. fastapi/__init__.py

    from .background import BackgroundTasks as BackgroundTasks
    from .datastructures import UploadFile as UploadFile
    from .exceptions import HTTPException as HTTPException
    from .exceptions import WebSocketException as WebSocketException
    from .param_functions import Body as Body
    from .param_functions import Cookie as Cookie
    from .param_functions import Depends as Depends
    from .param_functions import File as File
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:31:47 GMT 2024
    - 1.1K bytes
    - Viewed (0)
  5. docs_src/websockets/tutorial002_an_py310.py

    from typing import Annotated
    
    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
            <form action="" onsubmit="sendMessage(event)">
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.8K bytes
    - Viewed (0)
  6. fastapi/exceptions.py

            FastAPI,
            WebSocket,
            WebSocketException,
            status,
        )
    
        app = FastAPI()
    
        @app.websocket("/items/{item_id}/ws")
        async def websocket_endpoint(
            *,
            websocket: WebSocket,
            session: Annotated[str | None, Cookie()] = None,
            item_id: str,
        ):
            if session is None:
                raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 4.9K bytes
    - Viewed (0)
  7. docs_src/websockets/tutorial002.py

    from typing import Union
    
    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
            <form action="" onsubmit="sendMessage(event)">
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Nov 13 16:10:54 GMT 2022
    - 2.8K bytes
    - Viewed (0)
  8. docs_src/websockets/tutorial002_an.py

    from typing import Union
    
    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.8K bytes
    - Viewed (0)
  9. docs_src/websockets/tutorial002_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import (
        Cookie,
        Depends,
        FastAPI,
        Query,
        WebSocket,
        WebSocketException,
        status,
    )
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    html = """
    <!DOCTYPE html>
    <html>
        <head>
            <title>Chat</title>
        </head>
        <body>
            <h1>WebSocket Chat</h1>
            <form action="" onsubmit="sendMessage(event)">
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.8K bytes
    - Viewed (0)
  10. docs/en/docs/advanced/websockets.md

        ```Python hl_lines="68-69  81"
        {!> ../../../docs_src/websockets/tutorial002.py!}
        ```
    
    !!! info
        As this is a WebSocket it doesn't really make sense to raise an `HTTPException`, instead we raise a `WebSocketException`.
    
        You can use a closing code from the <a href="https://tools.ietf.org/html/rfc6455#section-7.4.1" class="external-link" target="_blank">valid codes defined in the specification</a>.
    
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 6.2K bytes
    - Viewed (0)
Back to top