Skip to content

Tag: fastapi

How to clear a dictionary after return?

I am having issue cleaning dictionaries after return the one. I am using fastAPI and my API GET an Age value then I create a list of ages with 4 values including my received value. I am looking to receive always 4 values only the input age and the other ones, in first execution the code works correctly but if

How to pass URL as a path parameter to a FastAPI route?

I have created a simple API using FastAPI, and I am trying to pass a URL to a FastAPI route as an arbitrary path parameter. When I test it, it doesn’t work and throws an error. I am testing it this way: Answer Option 1 You can simply use the path convertor to capture arbitrary paths. As per Starlette do…

Can not get cookie from localhost websocket fast api

I’m testing websockets to work with cookies and trying to get them in fast api. I manually installed them in chrome but I get an empty dictionary inside the application. I used the fast api documentation templates and slightly redesigned it My html My websocket print(websocket.cookies) returns an empty …

FastAPI FileResponse cannot find file in TempDirectory

I’m trying to write an endpoint that just accepts an image and attempts to convert it into another format, by running a command on the system. Then I return the converted file. It’s slow and oh-so-simple, and I don’t have to store files anywhere, except temporarily. I’d like all the fi…

How to update a single value in redis hash

I’m using Python FastAPI with redis. I wrote a function to update values in a redis hash, but I couldn’t able to update a single value alone, I could only able to re-write the whole hash. My model: My function: Answer hmset is deprecated for hset – but if you want to only update a single key…