Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for client_host (0.06 sec)

  1. docs_src/using_request_directly/tutorial001_py39.py

    from fastapi import FastAPI, Request
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    def read_root(item_id: str, request: Request):
        client_host = request.client.host
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 230 bytes
    - Viewed (0)
  2. tests/test_tutorial/test_using_request_directly/test_tutorial001.py

    client = TestClient(app)
    
    
    def test_path_operation():
        response = client.get("/items/foo")
        assert response.status_code == 200
        assert response.json() == {"client_host": "testclient", "item_id": "foo"}
    
    
    def test_openapi():
        response = client.get("/openapi.json")
        assert response.status_code == 200
        assert response.json() == {
            "info": {
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 3.8K bytes
    - Viewed (0)
Back to top