Skip to content
Advertisement

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 documentation,

Is it a good idea to use JWT as verification token?

I’m going to use FastAPI Users for my application. I saw that it generates JWT tokens to perform verification processes in the application. For example, in order to verify user email address or to request password change. Is it a good idea in terms of security? Answer JWT is state-less authentication and is so useful if you use backend with

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 dictionary {} Answer Cookies are domain-defined, so you should point at

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 file-writing to happen in a temporary directory, so it gets

Set Optional params in PUT method using fastAPI/mongodb

I am trying to set Optional some params in a PUT method from my API. Using fastAPI and mongodb I’ve build a simple API to insert students and delete the ones, now I am looking to allow me update the entries but not mandatory “params”. I’ve checked this Fastapi: put method and looks like something I am looking for mongodb.

Pydantic validation error for BaseSettings model with local ENV file

I’m developing a simple FastAPI app and I’m using Pydantic for storing app settings. Some settings are populated from the environment variables set by Ansible deployment tools but some other settings are needed to be set explicitly from a separate env file. So I have this in config.py And I have this config.txt So project_mode env var is being set

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, do not send

how to design a fastapi app with independent background computation?

I’ve created a python main application main.py, which I invoke with uvicorn main.main –reload. Which of course runs the following code… That part of the application runs constantly, reads data an processes it until the application is aborted manually. I use asyncio to run coroutines. Task I would like to build a small html dashboard on it, which can display

Advertisement