Category "fastapi"

Reading Cookie from React (backend with FastAPI + fastapi-jwt-auth)

I am having some problems with understanding JWT in Cookie using Axios and FastAPI. I am trying to make a simple application with React for the frontend and Fas

How to post an image file with a list of strings using FastAPI?

I have tried a lot of things, but it doesn't seem to work. Here is my code: @app.post("/my-endpoint") async def my_func( languages: List[str] = ["en", "hi"]

FastAPI Textarea OpenAPI for Form Data

I am using Form Data format for APIs. The thing is how I am going to make OpenAPI input being larger by using textarea?

FastAPI - Dataframe updated change lost between route

I'm trying to make a simple FastAPI api. Let's suppose these routes: The POST Route @api.post('/user', name='Get list of users') def get_user(user: User):

Response file stream from S3 FastAPI

I am trying to return a response of a picture from S3. In StreamingResponse.stream_response I see, that chunks are read from the stream and sent to the socket.

Async SqlAlchemy with FastAPI: Getting single session for all requests

I have recently migrated a REST API coded with FastApi to the new SQLAlchemy 1.4+ Async Version. My app compiles correctly and the database seems to setup just

python websocket pub-sub with re-publish/broadcast

I would like to set-up a server that can subscribe to an external stream over a websocket (ws_ext) and then republish that data (after curating) to internal cli

Handling the token expiration in fastapi

I'm new with fastapi security and I'm trying to implement the authentication thing and then use scopes. The problem is that I'm setting an expiration time for t

Incorrect Access-Control-Allow-Origin being added automatically to POST & DELETE endpoints [closed]

I have an app built with FastAPI hosted on API Gateway using serverless. The API: https://xxxxx.execute-api.xx-xxxxxx-x.amazonaws.com/dev/{pro

FastAPI OAuth2PasswordRequestForm dependency causing request failure

I'm using the auth scheme detailed in FastAPI's user guide (JWT/Bearer token). When I try to get a token from the /token endpoint the request fails before the p

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