Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 1 of 1 for write_log (0.04 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. docs_src/background_tasks/tutorial002_py39.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: Union[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}")
    Created: Sun Dec 28 07:19:09 GMT 2025
    - Last Modified: Wed Dec 17 20:41:43 GMT 2025
    - 675 bytes
    - Click Count (0)
Back to Top