Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 71 for writeTo (0.15 sec)

  1. docs_src/background_tasks/tutorial002_an_py310.py

    from fastapi import BackgroundTasks, Depends, FastAPI
    
    app = FastAPI()
    
    
    def write_log(message: str):
        with open("log.txt", mode="a") as log:
            log.write(message)
    
    
    def get_query(background_tasks: BackgroundTasks, q: str | None = None):
        if q:
            message = f"found query: {q}\n"
            background_tasks.add_task(write_log, message)
        return q
    
    
    @app.post("/send-notification/{email}")
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 683 bytes
    - Viewed (1)
  2. tests/test_tutorial/test_request_files/test_tutorial001_03.py

        path = tmp_path / "test.txt"
        path.write_bytes(b"<file content>")
    
        client = TestClient(app)
        with path.open("rb") as file:
            response = client.post("/files/", files={"file": file})
        assert response.status_code == 200, response.text
        assert response.json() == {"file_size": 14}
    
    
    def test_post_upload_file(tmp_path):
        path = tmp_path / "test.txt"
        path.write_bytes(b"<file content>")
    
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jun 30 18:25:16 GMT 2023
    - 6K bytes
    - Viewed (0)
  3. fastapi/security/oauth2.py

                    For example, a single string with:
    
                    ```python
                    "items:read items:write users:read profile openid"
                    ````
    
                    would represent the scopes:
    
                    * `items:read`
                    * `items:write`
                    * `users:read`
                    * `profile`
                    * `openid`
                    """
                ),
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 21.1K bytes
    - Viewed (1)
  4. .github/workflows/publish.yml

        types:
          - created
    
    jobs:
      publish:
        runs-on: ubuntu-latest
        strategy:
          matrix:
            package:
              - fastapi
              - fastapi-slim
        permissions:
          id-token: write
        steps:
          - name: Dump GitHub context
            env:
              GITHUB_CONTEXT: ${{ toJson(github) }}
            run: echo "$GITHUB_CONTEXT"
          - uses: actions/checkout@v4
          - name: Set up Python
    Others
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 30 06:38:13 GMT 2024
    - 1K bytes
    - Viewed (0)
  5. docs/en/docs/benchmarks.md

    * **Uvicorn**:
        * Will have the best performance, as it doesn't have much extra code apart from the server itself.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 3.4K bytes
    - Viewed (0)
  6. docs/en/docs/alternatives.md

    That's why, as said in the official website:
    
    > Requests is one of the most downloaded Python packages of all time
    
    The way you use it is very simple. For example, to do a `GET` request, you would write:
    
    ```Python
    response = requests.get("http://example.com/some/url")
    ```
    
    The FastAPI counterpart API *path operation* could look like:
    
    ```Python hl_lines="1"
    @app.get("/some/url")
    def read_url():
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 23.2K bytes
    - Viewed (0)
  7. docs/en/docs/tutorial/first-steps.md

    ## Recap
    
    * Import `FastAPI`.
    * Create an `app` instance.
    * Write a **path operation decorator** (like `@app.get("/")`).
    * Write a **path operation function** (like `def root(): ...` above).
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu May 02 22:37:31 GMT 2024
    - 12K bytes
    - Viewed (0)
  8. docs/en/docs/tutorial/testing.md

    Create functions with a name that starts with `test_` (this is standard `pytest` conventions).
    
    Use the `TestClient` object the same way as you do with `httpx`.
    
    Write simple `assert` statements with the standard Python expressions that you need to check (again, standard `pytest`).
    
    ```Python hl_lines="2  12  15-18"
    {!../../../docs_src/app_testing/tutorial001.py!}
    ```
    
    !!! tip
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:53:19 GMT 2024
    - 6.2K bytes
    - Viewed (0)
  9. docs/ja/docs/tutorial/background-tasks.md

    ```Python hl_lines="14"
    {!../../../docs_src/background_tasks/tutorial001.py!}
    ```
    
    `.add_task()` は以下の引数を受け取ります:
    
    * バックグラウンドで実行されるタスク関数 (`write_notification`)。
    * タスク関数に順番に渡す必要のある引数の列 (`email`)。
    * タスク関数に渡す必要のあるキーワード引数 (`message="some notification"`)。
    
    ## 依存性注入
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Mon Jan 15 16:12:39 GMT 2024
    - 6.1K bytes
    - Viewed (0)
  10. docs/em/docs/tutorial/request-files.md

    `UploadFile` ✔️ 📄 `async` 👩‍🔬. 👫 🌐 🤙 🔗 📁 👩‍🔬 🔘 (⚙️ 🔗 `SpooledTemporaryFile`).
    
    * `write(data)`: ✍ `data` (`str` ⚖️ `bytes`) 📁.
    * `read(size)`: ✍ `size` (`int`) 🔢/🦹 📁.
    * `seek(offset)`: 🚶 🔢 🧘 `offset` (`int`) 📁.
        * 🤶 Ⓜ., `await myfile.seek(0)` 🔜 🚶 ▶️ 📁.
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Wed Mar 13 19:02:19 GMT 2024
    - 6.6K bytes
    - Viewed (0)
Back to top