Skip to main content

Questions tagged [fastapi]

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.

Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

If I update the dependencies to the latest, I cannot see the traces

I am having a FastAPI (0.95.9) application. Using gunicorn with uvicorn.workers.UvicornWorker workers. I am trying to auto-instrument it and pass data to a self-hosted Signoz platform. When the ...
user2465039's user avatar
-1 votes
0 answers
45 views

How to send/receive a JSON dict in FastAPI: value is not a valid dict [duplicate]

I need help with basic stuff again... I think the question is essentially, why can I not send and receive JSON? ITT client-side error 192.168.2.250:54636 - "POST /itt HTTP/1.1" 422 ...
Innovations Anonymous's user avatar
0 votes
1 answer
36 views

Why is db not associated with a value

This is the code for an inventory manager, I started the API, checked if it was up, than ran a test file. I have been geting internal server errors, it's saying db is not associated with a value but ...
Rayaan Study's user avatar
0 votes
0 answers
13 views

Webrtc with aiohttp works but not fastapi

I have a sample application (https://github.com/pushkarprasad007/llm-aiortc) which uses aiortc, where User is supposed to send the audio and then its recorded on python server on backend, and then ...
Ouroboros's user avatar
  • 1,486
0 votes
0 answers
11 views

sending email through fastAPI_mail

env_values = dotenv_values(".env") env_values = dict(env_values) config = ConnectionConfig( MAIL_USERNAME =env_values["USER"], MAIL_PASSWORD = env_values["PASSWORD&...
Himanshu's user avatar
0 votes
0 answers
21 views

SQLAlchemy not executing update unless walking through code with debugger

I am genuinely baffled by the behavior I'm seeing so I'm hoping someone can shed some light onto what's going on here. Basically, I have a web app using FastAPI and SQLAlchemy in the back end that ...
Daniel Auerbach's user avatar
0 votes
0 answers
25 views

How to stop Ollama model streaming

So I have this class that streams the response form a model: from langchain_community.llms.ollama import Ollama from app.config import ( LLM_MODEL_NAME, MAX_LLM_INPUT_LENGTH, ...
KZiovas's user avatar
  • 4,347
1 vote
1 answer
33 views

Alembic not recognizing multiple models, using FastAPI

i am using sqlalchemy[asyncio], sqlalchemy, fastapi, alembic, asyncmy. my database is mysql and have the following project structure: core/ ├─ database.py ├─ settings.py alemibc/ ├─ versions/ ├─ env....
coding_billi's user avatar
-1 votes
1 answer
42 views

Bulk insert into SQL Server from python

I have a FastAPI endpoint in python that needs to insert a few thousand rows into a SQL Server table. I have the data in a pandas dataframe and currently I'm looping over the dataframe and inserting ...
KrokeWaan's user avatar
0 votes
0 answers
27 views

Trying to create a one-to-many relationship in both directions

All, thanks for taking the time to help. Basically, I have a table called Task that has a one-to-many relationship with a table called Label. This works just fine. I can assign every label I create ...
Jon Hayden's user avatar
0 votes
0 answers
14 views

Unable to access FastApi app that is running as windows service created with pywin32

i have a basic fastapi main.py as following: from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware app = FastAPI() origins = ["*"] app.add_middleware( ...
Jaydeep's user avatar
  • 795
0 votes
1 answer
20 views

Get path template from starlette request from a middleware

I am building a middleware to log calls to functions among other things. I have read about FastAPI: How to get raw URL path from request?, which suggests to use request.scope.get("route"), ...
Sarah's user avatar
  • 39
0 votes
1 answer
21 views

How to create daemon unit for fastapi server with poetry?

I created a shell script for start my fastapi server which located in my-dir. It works properly when I run it with ./script.sh. Server runs. #!/bin/bash poetry run python main.py Now I want to ...
CarloDiPalma's user avatar
0 votes
0 answers
9 views

Unable to fetch metadata from Redis backend when using FASTAPI endpoint (via polling) that was added by celery worker

I am implementing queue management using Celery to get estimated time and queue position for any task though polling every 10 secs. Teck Stack: Using Redis as Message Broker and Backend to store state ...
SaumyaG's user avatar
2 votes
1 answer
47 views

Set Pydantic BaseModel field type dynamically when instantiating an instance?

With Pydantic is it possible to build a model where the type of one of its fields is set via an argument when creating an instance? For example: class Animal(BaseModel): name: str class Dog(...
Matt Sanders's user avatar
  • 9,793
0 votes
0 answers
21 views

playwright failing when running in docker container

I have a simple fastapi app where i use playwright in to scrape the internet. it runs perfectly locally but when i run it in the container it fails I am using the official playwright image mcr....
Crazy Z's user avatar
  • 21
0 votes
0 answers
19 views

How to call the root page in a Fast API app from another route

I have a root route in FastAPI that connects to a MySQL db and returns a couple of rows from the db. import mysql.connector from typing import Annotated from fastapi import FastAPI, HTTPException, ...
Phlip's user avatar
  • 3
0 votes
0 answers
36 views

CRUD operation with FastAPI and sqlalchemy

I'm new to python and fastapi and i'm to create a simple CRUD to create a user and if the user gets created correctly, create a blank profile with the user_id of the created user. These are my Profile ...
Diego Rios's user avatar
0 votes
0 answers
12 views

How to avoid showing anyio.WouldBlock errors in middleware?

Description I have a similar issue as in https://github.com/tiangolo/fastapi/discussions/10387, but upgrading fastapi and starlette did not fix my issue When the app fails, instead of seeing an error ...
Sarah's user avatar
  • 39
-1 votes
0 answers
21 views

Wrong http header IP address for client when running FastAPI application in Docker container

I am running a FastAPI application (backend) which has some logic which depends on the ip address of the client which is connecting to the backend. Here is some example code which shows how the client ...
FreelanceConsultant's user avatar
-1 votes
0 answers
67 views

Cannot connect websocket via Nginx when using FastAPI

I'm trying to run a simple service with websocket to make it work through nginx. This is what my files look like (their code is below). When I run this on a local PC (Windows 10), it works correctly, ...
AIR's user avatar
  • 1
3 votes
2 answers
47 views

the values of ENUM type in SQLAlchemy with PostgreSQL is the variable not the value?

so my problem is i am trying to make an enum with int values but it didn't work. first of all, this is the code. class UserRole(enum.IntEnum): publisher = 4 editor = 3 manager = 2 ...
ibrahim shazly's user avatar
1 vote
1 answer
26 views

FastAPI curl works inside a container. curl on host machine: Connection reset by peer

I have a FastAPI instance running inside a container. when I exec bash into it, I can run what's below and it works: root@974b874a42eb:/code# curl http://localhost:9090 {"id":"e80c3468-...
Pompey Magnus's user avatar
0 votes
1 answer
32 views

How to pass client ip address via Nginx reverse proxy to FastAPI

I am trying to pass the request client IP address to a FastAPI backend via Nginx. Example FastAPI endpoint: @app.post('/api/example') def send_order(data: SomeDataType, request: Request, response: ...
FreelanceConsultant's user avatar
0 votes
0 answers
18 views

FastAPI uvicorn starrlette gradio package errors

I am trying to upgrade a gradio app to the latest version. I have been able to get the app running again but it's throwing server errors when i go to the browser. I am getting the following errors ...
Husk Rekoms's user avatar
0 votes
1 answer
39 views

Inverted Inheritance Structure in Pydantic

I know the normal way of creating Models in Pydantic is by Subclassing and adding fields for example like this: from pydantic import BaseModel class Base(BaseModel): task_id: str task_type: ...
AliSot 2000's user avatar
1 vote
0 answers
18 views

ConnectionRefusedError: [Errno 111] Connection refused. Docker, Python [duplicate]

I made a fastapi, alembic, postgres, sqlalchemy application, made a docker image, run http://127.0.0.1:8000/docs and try to create a user, but when sending a request I get the error ...
123 123's user avatar
  • 11
0 votes
1 answer
25 views

405 (Method Not Allowed) Error in Vercel FastAPI Backend (But Works Locally)

I have just deployed my NextJS-frontend/FastAPI-backend app on Vercel, and I am currently running into an issue that seems related to CORS that is giving me a 405 Method Not Allowed when I try to POST/...
theGreenCabbage's user avatar
0 votes
0 answers
46 views

Python fastapi asyncio or threading + multiprocessing, which is better approach [closed]

Please help me find out a best (better) approach to use multiprocessing with fastapi I have a project where i have one endpoint. Where heavy ocr model(easyocr) is imported and initialized in different ...
ReYaN WTF's user avatar
0 votes
0 answers
42 views

Filtering JSON Field in PostgreSQL with SQLAlchemy

I'm working with a PostgreSQL database using SQLAlchemy in fastAPI, and I need to filter results based on a value in a JSON array column. However, I'm encountering an issue where the filter does not ...
Menryck's user avatar
  • 169
1 vote
1 answer
40 views

Swagger API : should not accept Null

I have added the following to the swagger definition for the api. value : BooleanEnum = Query ( False, alias="value") class BooleanEnum(str, Enum): true = "true" false = &...
Tanu's user avatar
  • 1,454
0 votes
1 answer
45 views

Python asyncio + multiprocessing [duplicate]

I am trying to create a server with fastapi with multiprocessing, where you can send an image to a given endpoint, and it will be processed concurrently via 3 different ocr models to recognize text. ...
ReYaN WTF's user avatar
-2 votes
1 answer
41 views

Access to XMLHttpRequest X from origin Y has been blocked by CORS policy: Response to preflight request doesn't pass access control check

Access to XMLHttpRequest X from origin Y has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the ...
FreelanceConsultant's user avatar
0 votes
0 answers
39 views

Solving CORS issues between my fastapi and flutter application [closed]

I have a fastapi server running in my local network and want to make a request to that server using flutter. I am allowing all origins inside my main.py app = FastAPI(lifespan=lifespan) origins = [ ...
jack's user avatar
  • 25
2 votes
1 answer
39 views

How to use Depends and Path at the same time in FastAPI?

I have the following endpoint: @router.get('/events/{base_id}') def asd(base_id: common_input_types.event_id) -> None: do_something() And this is common_input_types.event_id: event_id = ...
Kulu's user avatar
  • 143
0 votes
1 answer
34 views

Return fastapi http exception to fron from langchain runnable

My backend is running langchain routes with certain runnables. I want to be able to return an http exception like "404 Not found" to the front end, but when I raise it with with raise ...
Carles Roch Arnau's user avatar
0 votes
0 answers
17 views

pytest anyio - create a mongodb motor fixture that lasts throughout session

I want to create a mongodb session with motor that will start and end with the tests with pytest and the anyio pytest plugin. But after tests are run, the entries persist in the database. # db.py ...
ffempegging's user avatar
0 votes
0 answers
24 views

How to resolve "RuntimeError: There is no current event loop in thread 'MainThread'" for Tortoise ORM and Celery in FastAPI

I have just started working with Tortoise ORM in FastAPI. This is also the first time I am using an ORM in FastAPI. I have a Celery task that performs some actions and then updates the database using ...
Neha's user avatar
  • 97
0 votes
0 answers
8 views

Post docker.container.logs asynchronous as SSE using fast-api and docker

I am trying to create an API that can fetch logs from a docker container and returns them as an event-stream. I use python as language together with the fastapi and docker package. Whenever I try to ...
AdrianG's user avatar
-1 votes
0 answers
22 views

Unit Tests in FastAPI with Prisma ORM

How to write unit tests for a FastAPI application with the Prisma client? I already looked in the documentation and code examples but couldn't find it. I have this code, but I don't know how to create ...
Mauricio Maciel's user avatar
0 votes
0 answers
16 views

Celery + Redis + Python: WorkerLostError(billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGABRT) Job: 0.)

While trying to use Celery with Redis as the broker for my FastAPI appilcation, where each endpoint makes use of memory-intensive functions with diffusers models, now I am facing an error saying ...
Rauhan Ahmed's user avatar
-1 votes
0 answers
22 views

Failed to start uvicorn using systemd

I am trying to run my FastAPI application by uvicorn and systemd. But it fails with following error. I checked user, file permission and run the application from command line. systemctl status ...
SaifulDipak's user avatar
1 vote
1 answer
24 views

ValueError: callable <dependency_injector.providers.Singleton> is not supported by signature with MySQLDatabase

I'm encountering an issue with dependency_injector.providers.Singleton in my Python application when trying to instantiate MySQLDatabase. Here's a simplified version of my code: import logging from ...
Sami Ali's user avatar
  • 127
0 votes
0 answers
17 views

Why freezegun.freezetime affects code outside of the freezetime context

Can anyone help me, how can I use freezegun to freeze time only in one request? @router.get('/debug') async def debug_route(request): debug_datetime = request.headers.get('Debug-datetime') ...
Mike Lastin's user avatar
0 votes
1 answer
19 views

authlib + mailchimp oauth2: invalid_client: client_id parameter missing

I'm building out an OAuth2 Factory using authlib and FastAPI because my upstream application needs to authenticate with multiple providers. The authentication factory works well with all providers ...
littleK's user avatar
  • 19.9k
0 votes
0 answers
54 views

Race condition using FastAPI, SQLAlchemy and Asyncpg

I am currently having problems solving an issue with writing data in the postgres db due to a race condition. Basically, I need to insert into the database a "Medico" if it doesn't exists. ...
João's user avatar
  • 13
-1 votes
0 answers
37 views

FastAPI endpoint downloading incorrect content from file URL

I have a FastAPI backend running locally on port 8000. I also have Liferay running locally via Docker. Files can be uploaded via Liferay. The upload triggers an event, which sends the URL of the file ...
kano's user avatar
  • 19
0 votes
0 answers
19 views

How to properly stop a python proxy server for react without blocking the terminal (main thread)

Right now, I have a proxy server that is started like so: An endpoint is called by the user which starts the proxy server and redirects to the proxy origin URL React const loginURL = `${process.env....
rasputin's user avatar
0 votes
1 answer
34 views

discord.py (with cogs) + FastAPI: errno -3 temporary failure in name resolution [solved while posting]

I've got what I would consider a fairly basic attempt at starting discord.py under FastAPI. It just crashes with errno -3 temporary failure in name resolution I've included most of the relevant code, ...
Innovations Anonymous's user avatar
1 vote
1 answer
70 views

Poetry permission denied

This is the content of my dockerfile. I am trying to dockerise a fastapi application but I have been running into an error for a long time. # syntax=docker/dockerfile:1 # Comments are provided ...
dhebbie Godspride's user avatar

1
2 3 4 5
141