Category "fastapi"

FastAPI @repeat_every throws 'Depends' object has no attribute 'query'

I am new to FastAPI. I want to use repeat_every() to generate bills from some sensor reading periodically. I wrote the following code but I am getting 'Depends'

Celery Beat doesn't follow schedule Fast API

This celery beat scheduler says the max tick is 5 minutes. I am developing things here so firstly it needs to automatically pick up the right times to run. Seem

How to configure pytest in FastAPI?

I'm trying to write some tests for my FastAPI -application. I have defined app in main.py like this: app = FastAPI(). I try to import this in my test test_api.p

Unable to achieve async/parallel behavior inside for loop while using FastAPI and Ormar

I am using FastAPI and have an async route that needs to do many things like making calls to other API endpoints, and reading/writing to a database. It iterates

Python: FastAPI error 422 with post request

I'm building a simple API to test a database. When I use get request everything works fine, but if I change to post I get "unprocessable entity" error: Here is

How to use url_for() to pass path and query data to a route using FastAPI and Jinja2

I want to call a FastAPI route from a jinja2 template and pass both path and query data to the called route. All my attempts fail. I tried something in the jinj

A minimal fastapi example loading index.html

In my project folder I have a basic index.html file plus static files (js, css) as well as my main.py: from fastapi.staticfiles import StaticFiles from fastapi.

Mock Dependency classes in FastAPI

I have an api which is representative of the structure of: from fastapi import FastAPI, Depends, Request, APIRouter class SomeManager: def get_value_from

How to get file path from UploadFile in FastAPI?

Basically, I'm trying to create an endpoint to Upload files to Amazon S3. async def upload_files(filepath: str, upload_file_list: List[UploadFile] = File(...)):

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

Specifically, I want the below example to work: from typing import List from pydantic import BaseModel from fastapi import FastAPI, UploadFile, File app = Fas

Can't print a dict: Uncaught TypeError: Cannot read properties of undefined

I've this error: crew.js:6 Uncaught TypeError: Cannot read properties of undefined (reading 'first') From an API (I'm using FastAPI for backend) I've this ret

Pydantic enum field does not get converted to string

I am trying to restrict one field in a class to an enum. However, when I try to get a dictionary out of class, it doesn't get converted to string. Instead it re

Using pytest with FastAPI + Tortoise : tortoise.exceptions.DBConnectionError: Can't establish connection to database

I have two postgres databases, one for prod and another for testing in "DATABASE_URI" and "TESTDATABASE_URI" respectively. The app seems to working perfectly, w

FastAPI runs api-calls in serial instead of parallel fashion

I have the following code: import time from fastapi import FastAPI, Request app = FastAPI() @app.get("/ping") async def ping(request: Request):

How can I skip authentication in a single test with a fixture in Fast API together with pytest?

I have built authentication similar to what is described in the documentation. So I have this dependency copied from there: async def get_current_user(token: st

RuntimeError: CUDA out of memory with FastAPI

I try to make a backend server based on fastapi. My backend server works well with almost no errors, but I found an error situation. I allocate two services to

FastAPI: How to get raw URL path from request?

I have a GET method with request parameter in path: @router.get('/users/{user_id}') async def get_user_from_string(user_id: str): return User(user_id) Is i

FastAPI - GET Request with Pydantic List field

I'm new to FastAPI (migrating from Flask) and I'm trying to create a Pydantic model for my GET route: from fastapi import APIRouter,Depends from pydantic import

How to validate ObjectId query param in FastAPI

I have an endpoint that recibe and id field used to get data from MongoDB's _id: from fastapi import APIRouter from bson import ObjectId router = APIRouter()

TemplateResponse error in Video Streaming App using FastAPI

I am trying to render an HTML page that shows video streaming from a webcam. However, I am facing the following error: 500 Server Error TypeError: TemplateRespo