About 9,310,000 results
Open links in new tab
  1. Performance results differ between run_in_threadpool () and run_in ...

    Mar 28, 2024 · Using run_in_threadpool() FastAPI is fully compatible with (and based on) Starlette, and hence, with FastAPI you get all of Starlette's features, such as run_in_threadpool(). Starlette's …

  2. How to initialize a global object or variable and reuse it in every ...

    from fastapi import FastAPI, Request from contextlib import asynccontextmanager @asynccontextmanager async def lifespan(app: FastAPI): ''' Run at startup Initialize the Client and …

  3. FastAPI - How to get app instance inside a router?

    Since FastAPI is actually Starlette underneath, you could store the model on the application instance using the generic app.state attribute, as described in Starlette's documentation (see State class …

  4. FastAPI/uvicorn not working when specifying host [duplicate]

    The FastAPI/uvicorn server is not working when specifying the host.

  5. How to configure FastAPI logging so that it works both with Uvicorn ...

    Aug 29, 2023 · 1. Setting up the uvicorn logger Straight from the documentation: Logging --log-config <path> - Logging configuration file. Options: dictConfig() formats: .json, . yaml. Any other format will …

  6. fastapi @app.on_event decorator is deprecated, how can I create a ...

    Feb 22, 2024 · I have the following decorator that works perfectly, but fastapi says @app.on_event ("startup") is deprecated, and I'm unable to get @repeat_every () to work with lifespan. from …

  7. How to add both file and JSON body in a FastAPI POST request?

    Dec 30, 2020 · Whenever a new request arrives, FastAPI will take care of calling your dependency, getting the result and assigning that result to the parameter (e.g., base) in your endpoint. For more …

  8. How to run Uvicorn FastAPI server as a module from another Python …

    Sep 30, 2022 · I want to run FastAPI server using Uvicorn from A different Python file. uvicornmodule/main.py import uvicorn import webbrowser from fastapi import FastAPI from …

  9. python - How can I install fastapi properly? - Stack Overflow

    Dec 26, 2021 · The OP is trying to install fastapi[all] which seems to require compiling from source. No, I don't agree with you, I just provided the viable solution and I use it all the time. Thanks. The question …

  10. Add startup/shutdown handlers to FastAPI app with lifespan API

    Oct 25, 2023 · app.mount(mount_path, sub_app) How can I register startup/shutdown handlers for the sub app? All solutions I could find either require control over the lifespan generator (which I don't …