Skip to content
Advertisement

Tag: fastapi

ModuleNotFoundError: No module named ‘app’ fastapi docker

when i used docker-compose up -d ModuleNotFoundError: No module named ‘app’ the folders in Fastapi framework: fastapi app -main.py Dockerfile docker-compose Answer Your work directory is /app and the main.py file is already there. So you don’t need to call app.main module. Just call main.py script directly in CMD.

FastAPI – How to get app instance inside a router?

I want to get the app instance in my router file, what should I do ? My main.py is as follows: Now I want to use app.machine_learning_model in some_router’s file , what should I do ? Answer You should store the model on the app instance using the generic app.state attribute, as described in the documentation (see State class implementation

How to get wave module methods for reading a .wav audio but with a temporary file tempfile.SpooledTemporaryFile obtained from fastAPI post request?

I have a function that receives a .wav audio path directory and return its pcm_data in bytes, sample_rate as int and duration as float. Now I want that the audio file comes from a uploaded audio using POST request with FastAPI, so if I upload a .wav audio using the UploadFile class from fastapi, I get a tempfile.SpooledTemporaryFile, how can

function object has no attribute ‘connect’

Seems there’s a problem with my sql alchemy connection, don’t get why? it works sometimes and then doesn’t the next. Also vs code isn’t auto recommending sql alchemy methods, maybe I’ve set it up wrong? –database.py file main file ERROR I GET: It seems to me that the query method from sql alchemy isnt working for some reason. It doesn’t

Conditional call of a FastAPI Model

I have a multilang FastAPI connected to MongoDB. My document in MongoDB is duplicated in the two languages available and structured this way (simplified example): I therefore implemented two models DatasetFR and DatasetEN, each one makeS references with specific external Models (Enum) for category and tags in each lang. In the routes definition I forced the language parameter to declare

FastAPI swagger does not render because of custom Middleware?

So I have a custom middleware like this: Its objective is to add some meta_data fields to every response from all endpoints of my FastAPI app. However, when I served my app using uvicorn, and launched the swagger URL, here is what I see: With a lot of debugging, I found that this error was due to the custom middleware

Send query params from Jinja template

I can’t figure out if it’s possible to pass query parameters from a static html page to a view for processing. I have now implemented the functionality I need using path parameters. I want to do the same, but with query parameters main.py events.py routes.py html It’s works with “POST /event/invite/15/sender/3 HTTP/1.1” as a sample Try with query params And

Advertisement