Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for add_process_time_header (0.19 sec)

  1. docs_src/middleware/tutorial001.py

    import time
    
    from fastapi import FastAPI, Request
    
    app = FastAPI()
    
    
    @app.middleware("http")
    async def add_process_time_header(request: Request, call_next):
        start_time = time.time()
        response = await call_next(request)
        process_time = time.time() - start_time
        response.headers["X-Process-Time"] = str(process_time)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 349 bytes
    - Viewed (0)
  2. fastapi/applications.py

            ```python
            import time
    
            from fastapi import FastAPI, Request
    
            app = FastAPI()
    
    
            @app.middleware("http")
            async def add_process_time_header(request: Request, call_next):
                start_time = time.time()
                response = await call_next(request)
                process_time = time.time() - start_time
    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