Search Options

Results per page
Sort
Preferred Languages
Advance

Results 451 - 460 of 1,127 for def2 (0.02 sec)

  1. tests/test_tutorial/test_testing/test_main.py

    from docs_src.app_testing.test_main import client, test_read_main
    
    
    def test_main():
        test_read_main()
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == {
            "openapi": "3.1.0",
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "paths": {
                "/": {
                    "get": {
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 819 bytes
    - Viewed (0)
  2. tests/test_tutorial/test_configure_swagger_ui/test_tutorial002.py

    from fastapi.testclient import TestClient
    
    from docs_src.configure_swagger_ui.tutorial002 import app
    
    client = TestClient(app)
    
    
    def test_swagger_ui():
        response = client.get("/docs")
        assert response.status_code == 200, response.text
        assert (
            '"syntaxHighlight": false' not in response.text
        ), "not used parameters should not be included"
        assert (
            '"syntaxHighlight.theme": "obsidian"' in response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Aug 19 19:54:04 UTC 2023
    - 1.5K bytes
    - Viewed (0)
  3. docs_src/request_files/tutorial001_03_an.py

    from fastapi import FastAPI, File, UploadFile
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    @app.post("/files/")
    async def create_file(file: Annotated[bytes, File(description="A file read as bytes")]):
        return {"file_size": len(file)}
    
    
    @app.post("/uploadfile/")
    async def create_upload_file(
        file: Annotated[UploadFile, File(description="A file read as UploadFile")],
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 431 bytes
    - Viewed (0)
  4. docs_src/separate_openapi_schemas/tutorial001_py310.py

    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
    
    
    app = FastAPI()
    
    
    @app.post("/items/")
    def create_item(item: Item):
        return item
    
    
    @app.get("/items/")
    def read_items() -> list[Item]:
        return [
            Item(
                name="Portal Gun",
                description="Device to travel through the multi-rick-verse",
            ),
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 25 19:10:22 UTC 2023
    - 451 bytes
    - Viewed (0)
  5. docs/em/docs/advanced/dataclasses.md

    7ī¸âƒŖ. đŸ“Ĩ `response_model` ⚙ī¸ 🆎 ✍ 📇 `Author` đŸŽģ.
    
        🔄, 👆 đŸ’Ē 🌀 `dataclasses` ⏎ī¸ 🐩 🆎 ✍.
    
    8ī¸âƒŖ. 👀 👈 👉 *➡ 🛠ī¸ đŸ”ĸ* ⚙ī¸ đŸĨ” `def` ↩ī¸ `async def`.
    
        🕧, FastAPI 👆 đŸ’Ē 🌀 `def` & `async def` đŸ’Ē.
    
        đŸšĨ 👆 đŸ’Ē ↗ī¸ 🔃 🕐❔ ⚙ī¸ ❔, ✅ 👅 📄 _"🏃 ❓" _ đŸŠē 🔃 <a href="https://fastapi.tiangolo.com/async/#in-a-hurry" target="_blank" class="internal-link">`async` &amp; `await`</a>.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 3.4K bytes
    - Viewed (0)
  6. docs_src/websockets/tutorial002_an.py

                    input.value = ''
                    event.preventDefault()
                }
            </script>
        </body>
    </html>
    """
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    async def get_cookie_or_token(
        websocket: WebSocket,
        session: Annotated[Union[str, None], Cookie()] = None,
        token: Annotated[Union[str, None], Query()] = None,
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 2.8K bytes
    - Viewed (0)
  7. docs_src/websockets/tutorial002_an_py39.py

                    input.value = ''
                    event.preventDefault()
                }
            </script>
        </body>
    </html>
    """
    
    
    @app.get("/")
    async def get():
        return HTMLResponse(html)
    
    
    async def get_cookie_or_token(
        websocket: WebSocket,
        session: Annotated[Union[str, None], Cookie()] = None,
        token: Annotated[Union[str, None], Query()] = None,
    ):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 2.8K bytes
    - Viewed (0)
  8. tests/test_tutorial/test_response_model/test_tutorial003_py310.py

    from fastapi.testclient import TestClient
    
    from ...utils import needs_py310
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.response_model.tutorial003_py310 import app
    
        client = TestClient(app)
        return client
    
    
    @needs_py310
    def test_post_user(client: TestClient):
        response = client.post(
            "/user/",
            json={
                "username": "foo",
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Aug 04 20:47:07 UTC 2023
    - 5.8K bytes
    - Viewed (0)
  9. tests/test_tutorial/test_dependencies/test_tutorial004_an_py310.py

                200,
                {"items": [{"item_name": "Bar"}], "q": "bar"},
            ),
        ],
    )
    def test_get(path, expected_status, expected_response, client: TestClient):
        response = client.get(path)
        assert response.status_code == expected_status
        assert response.json() == expected_response
    
    
    @needs_py310
    def test_openapi_schema(client: TestClient):
        response = client.get("/openapi.json")
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 5.6K bytes
    - Viewed (0)
  10. tests/test_webhooks_security.py

    
    @app.webhooks.post("new-subscription")
    def new_subscription(
        body: Subscription, token: Annotated[str, Security(bearer_scheme)]
    ):
        """
        When a new user subscribes to your service we'll send you a POST request with this
        data to the URL that you register for the event `new-subscription` in the dashboard.
        """
    
    
    client = TestClient(app)
    
    
    def test_dummy_webhook():
        # Just for coverage
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Oct 20 09:00:44 UTC 2023
    - 4.6K bytes
    - Viewed (0)
Back to top