Category "fastapi"

How to run FastAPI app on multiple ports?

I have a FastAPI application that I am running on port 30000 using Uvicorn programmatically. Now I want to run the same application on port 8443 too. The same a

How can I reduce the number of database queries for a one to many association in Strawberry GraphQL and FastAPI?

I'm developing a python GraphQL API server using FastAPI and Strawberry, and I'm implementing this feature: I have two entities, User and Order, which have a on

FastApi settings / dependency

I have a FastAPI app with pydantic settings instance reading and validation env variables: ### config.py from pydantic import BaseSettings class Settings(BaseSe

How to send and receive data in XML format using WebSockets and FastAPI?

I'm trying to communicate with a fingerprint device. Actaully it sends data through websocket connection. So, I think I can communicate with the device using we

How to test a dockerized application in an Azure DevOps (Server) pipeline?

I have a simple python dockerized application whose structure is /src - server.py - test_server.py Dockerfile requirements.txt in which the docker base image

How to render Streamable image on React coming from the FastAPI

I want to render a StreamingResponse image on React from FastAPI. The image is in the form of numpy array which is of cv2 type of object @app.post("/predict") a

FastAPI: reject a WebSocket connection with HTTP response

In a FastAPI based Web app, I have a WebSocket endpoint that should allow connections only if some conditions are met, otherwise it should return an HTTP 404 re

FastAPI variable query parameters

I am writing a Fast API server that accepts requests, checks if users are authorized and then redirects them to another URL if successful. I need to carry over

How to generate Pydantic model for multiple different objects

I need to have a variable covars that contains an unknown number of entries, where each entry is one of three different custom Pydantic models. In this case, ea

when i use docker-compose to install a fastapi project, i got AssertionError:

when I use docker-compose to install a fastapi project, I got AssertionError: jinja2 must be installed to use Jinja2Templates but when I use env to install it,

SQLAlchemy: JOIN between different databases AND using different files in a module

Stack I am using: Python 3.10.x FastAPI 0.75.x SQLAlchemy 1.4.3x Summary I am building a unifying FastAPI project for several legacy databases (stored back-end

Fastapi returns 404 when accessing URL in the browser

I am learning fastapi and created the sample following application from fastapi import FastAPI import uvicorn app = FastAPI() @app.get("/hello") async def hell

FastAPI - dynamic inputs for different data types

I have to create a very generic endpoint for a user. The user may send JSON data or may upload a file to this endpoint. There are multiple options on how to han

Call async function in Enum

I want to refactor my code from sync to async. I use Python and FastAPI. I use the method which calls async function in Enumaration. For example: from enum impo

Header x-rapidapi-proxy-secret not forwarded by Heroku

I wrote and API with RapidAPI and deployed it on Heroku. I then listed the API on RapidAPI marketplace which uses a x-rapidapi-proxy-secret header to help me ma

fastapi : save image from response body

I want to save an image from the response body to my local directory. Here is my code: return Response(bytes_io.getvalue(), media_type= "image/jpeg")

Upload single image from axios to FastAPI: "Expected UploadFile, received: <class 'str'>"

I try to upload an image from my react-admin app to FastAPI using axios. The ImageInput component returns a File object which I cast to a Blob and try to upload

PendingRollbackError when accessing test database in FastAPI async test

I'm trying to mimic Django behavior when running tests on FastAPI: I want to create a test database in the beginning of each test, and destroy it in the end. Th

FastAPI asynchronous background tasks blocks other requests?

I want to run a simple background task in FastAPI, which involves some computation before dumping it into the database. However, the computation would block it

Interaction Between Flutter and FastAPI

Ubuntu 20.04LTS, with Python 3.8 for FastAPI, and Flutter 2.8.1, with Android SDK version 32.0.0. I am trying to send a Map from Flutter to FastAPI. I have figu