Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 42 for Log (0.66 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_background_tasks/test_tutorial002_an.py

    client = TestClient(app)
    
    
    def test():
        log = Path("log.txt")
        if log.is_file():
            os.remove(log)  # pragma: no cover
        response = client.post("/send-notification/******@****.***?q=some-query")
        assert response.status_code == 200, response.text
        assert response.json() == {"message": "Message sent"}
        with open("./log.txt") as f:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 571 bytes
    - Viewed (0)
  3. tests/test_tutorial/test_background_tasks/test_tutorial002_an_py310.py

        client = TestClient(app)
        log = Path("log.txt")
        if log.is_file():
            os.remove(log)  # pragma: no cover
        response = client.post("/send-notification/******@****.***?q=some-query")
        assert response.status_code == 200, response.text
        assert response.json() == {"message": "Message sent"}
        with open("./log.txt") as f:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 631 bytes
    - Viewed (0)
  4. .gitignore

    .idea
    .ipynb_checkpoints
    .mypy_cache
    .vscode
    __pycache__
    .pytest_cache
    htmlcov
    dist
    site
    .coverage
    coverage.xml
    .netlify
    test.db
    log.txt
    Pipfile.lock
    env3.*
    env
    docs_build
    site_build
    venv
    docs.zip
    archive.zip
    
    # vim temporary files
    *~
    .*.sw?
    .cache
    
    # macOS
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Aug 19 13:11:35 GMT 2023
    - 268 bytes
    - Viewed (0)
  5. docs_src/generate_clients/tutorial004.js

                operation.operationId = newOperationId
              }
            }
          }
        }
    
        await fs.promises.writeFile(
          filePath,
          JSON.stringify(openapiContent, null, 2),
        )
        console.log('File successfully modified')
      } catch (err) {
        console.error('Error:', err)
      }
    }
    
    const filePath = './openapi.json'
    JavaScript
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 14 11:40:05 GMT 2024
    - 1K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_background_tasks/test_tutorial002.py

    client = TestClient(app)
    
    
    def test():
        log = Path("log.txt")
        if log.is_file():
            os.remove(log)  # pragma: no cover
        response = client.post("/send-notification/******@****.***?q=some-query")
        assert response.status_code == 200, response.text
        assert response.json() == {"message": "Message sent"}
        with open("./log.txt") as f:
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 09 18:06:12 GMT 2020
    - 568 bytes
    - Viewed (0)
  7. docs_src/events/tutorial002.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.on_event("shutdown")
    def shutdown_event():
        with open("log.txt", mode="a") as log:
            log.write("Application shutdown")
    
    
    @app.get("/items/")
    async def read_items():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 255 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_events/test_tutorial002.py

            response = client.get("/items/")
            assert response.status_code == 200, response.text
            assert response.json() == [{"name": "Foo"}]
        with open("log.txt") as log:
            assert "Application shutdown" in log.read()
    
    
    def test_openapi_schema(app: FastAPI):
        with TestClient(app) as client:
            response = client.get("/openapi.json")
            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)
  9. docs/ja/docs/tutorial/background-tasks.md

    **FastAPI** は、それぞれの場合の処理​​方法と同じオブジェクトの再利用方法を知っているため、すべてのバックグラウンドタスクがマージされ、バックグラウンドで後で実行されます。
    
    ```Python hl_lines="13  15  22  25"
    {!../../../docs_src/background_tasks/tutorial002.py!}
    ```
    
    この例では、レスポンスが送信された *後* にメッセージが `log.txt` ファイルに書き込まれます。
    
    リクエストにクエリがあった場合、バックグラウンドタスクでログに書き込まれます。
    
    そして、*path operations 関数* で生成された別のバックグラウンドタスクは、`email` パスパラメータを使用してメッセージを書き込みます。
    
    ## 技術的な詳細
    
    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/en/docs/tutorial/security/get-current-user.md

    Do you want to just have a `str`? Or just a `dict`? Or a database class model instance directly? It all works the same way.
    
    You actually don't have users that log in to your application but robots, bots, or other systems, that have just an access token? Again, it all works the same.
    
    Plain Text
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Jan 11 16:31:18 GMT 2024
    - 7.6K bytes
    - Viewed (0)
Back to top