Category "fastapi"

FastAPI throws an error (Error loading ASGI app. Could not import module "api")

I tried to run FastAPI using uvicorn webserver but it throws an error. I run this command, uvicorn api:app --reload --host 0.0.0.0 but there is an error in the

FastAPI throws an error (Error loading ASGI app. Could not import module "api")

I tried to run FastAPI using uvicorn webserver but it throws an error. I run this command, uvicorn api:app --reload --host 0.0.0.0 but there is an error in the

FastApi create background task in a custom APIRoute

According to this tutorial you can create BackgroundTasks from the route function as follow: @app.post("/send-notification/{email}") async def send_notification

How to get current active user in middleware FastAPI python

I have developed an auth on FastAPI Python using the doc here https://fastapi.tiangolo.com/tutorial/security/oauth2-jwt/ (I use exactly the code shown, nothing

How do I return a dict + an image from a FastAPI endpoint?

I am trying to use FastAPI to allow my (dockerized) server to respond to API calls returning an image image, and a dictionary additional_dict (for a machine lea

How to run UVICORN in Heroku?

So I have figured out how to code a fastAPI and I am ready to deploy my script to heroku that I have worked with fastAPI (https://fastapi.tiangolo.com/) however

FastAPI websockets not working when using Redis pubsub functionality

currently I'm using websockets to pass through data that I receive from a Redis queue (pub/sub). But for some reason the websocket doesn't send messages when us

FastAPI cannot find main.py: `ERROR: Error loading ASGI app. Could not import module "main"

I know usually it is something about project structure that raises this error. But my project structure is the simplest one: . ├── blog.db

Is there a way to exclude Pydantic models from FastAPI's auto-generated documentation?

Is there a way for a FastAPI application to not display a model in its schema documentation? I have some models which are slight variations of others, and with

Meraki API - Redirect stdout, stderr to websocket or file

I'm using a Flask route to call the Meraky python library and trying to redirect the stdout and stderr of each API call to a websocket or eventually a log file,

Can I create a Teams bot without using Bot Framework?

I want to create MS Teams chat-bot without using MS Bot Framework. However, in the official document, there was only an example of using the MS Bot Framework. I

fastapi + aiomysql connection pool stuck after 10 calls

Why aiomysql connection pool stuck after N calls? (N is the maxsize number of connection. Tried the default N=10 and N=3) I thought the acquired connections are

FastAPI UploadFile is slow compared to Flask

If I create an endpoint like below: @app.post("/report/upload") def create_upload_files(files: UploadFile = File(...)): try: with open(files

Best way to override FastAPI dependencies for testing with a different dependency for each test

According to FastAPI official documentation the recommended way to override the dependencies for testing is to do it globally before all tests are run: asy

How to send a base64 encoded image to a FastAPI backend

I'm using code from this and that answer to send a base64 encoded image to a python FastAPI backend. The client side looks like this: function toDataURL(src, ca

How write logs to file with unicorn config

Its my uvicorn log_config.yaml. All works perfect untill i add logging to file. Its says to me ValueError: not enough values to unpack (expected 5, got 0) I tr

Requests format for uploading multiple images in FastAPI

Example Here's my code trying to upload a list of images: import requests import glob import cv2 path = glob.glob("test_folder/*", recursive=True) # a list of

FastAPI - How to render Jinja2 template with variable that contains special characters?

I'm trying to render this Jinja2 template: @app.get("/", response_class=HTMLResponse) async def read_root(request: Request, item: Optional[str] = None): ite

FastAPI TypeError: Object of type 'ModelMetaclass' is not JSON serializable

I'm getting this error, the models migrate successfully when i run uvicorn main:app --reload but when i tried to go to 127.0.0.1:8000/docs i got this error. I'm

FastAPI: security with firebase token

I'm following this tutorial to create an api backend. I use firebase authentication: user input email and password at frontend front sends the info to firebase