Category "fastapi"

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

How to post JSON data to FastAPI backend without using Swagger UI?

I am trying to do a simple POST operation using FastAPI. I have created a basic structure using BaseModel, which has only two attributes, namely 'name' and 'rol

Making API Get query for multiple instances

I'm trying to build a web app with FastAPI. After lunching the web app and entering this URL into a web browser http://localhost:8080/mall/customers/segmentatio

FastAPI - Postman error 422 Unprocessable Entity

I am using FastAPI to make get/post/put/del requests, which all work perfectly fine in the browser. I wanted to use Postman to do the exact same thing; however,

Input 0 of layer "sequential_3" is incompatible with the layer: expected shape=(None, 256, 256, 3), found shape=(None, 324, 500, 3)

I'm having an issue if anyone can help please comment input_shape=(BATCH_SIZE,256,256,3) model=models.Sequential([ resize_and_rescale, data_aug

500 Undocumented Error: Internal Server Error when returning response in FastAPI

I am using FastAPI to make predictions using a ML model. When I give a task_id and input, the app should add it to the background task and return the response a

How to share variables between HTTP requests in FastAPI?

I wonder how can I share the value of variables between HTTP requests in FastAPI. For instance, I have a POST request in which I get some audio files and then I

Python ModuleNotFoundError while importing a module in conftest for Pytest framework

My project structure mt-kart | --> src/data_kart | | | -->apis | | | -->__init__.py |

FastAPI (starlette) get client real IP

I have an API on FastAPI and i need to get the client real IP address when he request my page. I'm ty to use starlette Request. But it returns my server IP, no

FastAPI: app.dependency_overrides affects other test files

I'm working with FastAPI. I've introduced in my test suite (pytest) app.dependency_overrides to test my app dependencies. Strangely enough, when I use it in a t

FastAPI - How to upload file via form

I am making a REST API that requires uploading files. For testing purposes, I am uploading files through postman, but I don't know how to access the files on se