Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 28 for events (0.24 sec)

  1. tests/test_router_events.py

        return State()
    
    
    @pytest.mark.filterwarnings(
        r"ignore:\s*on_event is deprecated, use lifespan event handlers instead.*:DeprecationWarning"
    )
    def test_router_events(state: State) -> None:
        app = FastAPI()
    
        @app.get("/")
        def main() -> Dict[str, str]:
            return {"message": "Hello World"}
    
        @app.on_event("startup")
        def app_startup() -> None:
            state.app_startup = True
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 3.2K bytes
    - Viewed (0)
  2. tests/test_tutorial/test_events/test_tutorial003.py

    from fastapi.testclient import TestClient
    
    from docs_src.events.tutorial003 import (
        app,
        fake_answer_to_everything_ml_model,
        ml_models,
    )
    
    
    def test_events():
        assert not ml_models, "ml_models should be empty"
        with TestClient(app) as client:
            assert ml_models["answer_to_everything"] == fake_answer_to_everything_ml_model
            response = client.get("/predict", params={"x": 2})
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 3.6K bytes
    - Viewed (0)
  3. tests/test_sub_callbacks.py

    )
    def invoice_notification(body: InvoiceEvent):
        pass  # pragma: nocover
    
    
    class Event(BaseModel):
        name: str
        total: float
    
    
    events_callback_router = APIRouter()
    
    
    @events_callback_router.get("{$callback_url}/events/{$request.body.title}")
    def event_callback(event: Event):
        pass  # pragma: nocover
    
    
    subrouter = APIRouter()
    
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.8K bytes
    - Viewed (0)
  4. tests/test_tutorial/test_events/test_tutorial001.py

    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="app", scope="module")
    def get_app():
        with pytest.warns(DeprecationWarning):
            from docs_src.events.tutorial001 import app
        yield app
    
    
    def test_events(app: FastAPI):
        with TestClient(app) as client:
            response = client.get("/items/foo")
            assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 3.6K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_events/test_tutorial002.py

    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="app", scope="module")
    def get_app():
        with pytest.warns(DeprecationWarning):
            from docs_src.events.tutorial002 import app
        yield app
    
    
    def test_events(app: FastAPI):
        with TestClient(app) as client:
            response = client.get("/items/")
            assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 18 12:36:40 GMT 2023
    - 1.4K bytes
    - Viewed (0)
  6. docs/extensions/s3zip/examples/boto3/main.py

            config=Config(signature_version='s3v4'),
            region_name='us-east-1')
    
    
    def _add_header(request, **kwargs):
        request.headers.add_header('x-minio-extract', 'true')
    event_system = s3.meta.events
    event_system.register_first('before-sign.s3.*', _add_header)
    
    # List zip contents
    response = s3.list_objects_v2(Bucket="your-bucket", Prefix="path/to/file.zip/")
    print(response)
    
    Python
    - Registered: Sun Apr 28 19:28:10 GMT 2024
    - Last Modified: Wed Aug 04 21:15:45 GMT 2021
    - 771 bytes
    - Viewed (0)
  7. fastapi/routing.py

                    """
                ),
            ],
        ) -> Callable[[DecoratedCallable], DecoratedCallable]:
            """
            Add an event handler for the router.
    
            `on_event` is deprecated, use `lifespan` event handlers instead.
    
            Read more about it in the
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 170.1K bytes
    - Viewed (0)
  8. fastapi/applications.py

            return decorator
    
        @deprecated(
            """
            on_event is deprecated, use lifespan event handlers instead.
    
            Read more about it in the
            [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/).
            """
        )
        def on_event(
            self,
            event_type: Annotated[
                str,
                Doc(
                    """
    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)
  9. docs_src/websockets/tutorial002_py310.py

                        var content = document.createTextNode(event.data)
                        message.appendChild(content)
                        messages.appendChild(message)
                    };
                    event.preventDefault()
                }
                function sendMessage(event) {
                    var input = document.getElementById("messageText")
                    ws.send(input.value)
    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)
  10. docs_src/websockets/tutorial003_py39.py

                ws.onmessage = function(event) {
                    var messages = document.getElementById('messages')
                    var message = document.createElement('li')
                    var content = document.createTextNode(event.data)
                    message.appendChild(content)
                    messages.appendChild(message)
                };
                function sendMessage(event) {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 2.5K bytes
    - Viewed (0)
Back to top