Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 1 year ago. Improve this question
Tag: fastapi
Set an optional endpoint parameter dynamically
What is the best way to set an optional endpoint parameter dynamically? Naively, I have tried with activated_on: Optional[date] = Depends(date.today) thinking FastAPI would call the callable, but it doesn’t work. Answer TL;DR Change the callable of your Depends to a helper function, and inject the optional value into the helper function instead of into the route function. This does
How to terminate a Uvicorn + FastAPI application cleanly with workers >= 2 when testing with pytest
I have an application written with Uvicorn + FastAPI. I am testing the response time using PyTest. Referring to How to start a Uvicorn + FastAPI in background when testing with PyTest, I wrote the test. However, I found the application process alive after completing the test when workers >= 2. I want to terminate the application process cleanly at
How to display list data from SqlAlchemy Query using fastAPI
So, I have been trying to learn Python Full-Stack web development using fastAPI. Most of my website works properly but I am having trouble with sending the list of Query using FASTAPI. I get this error. This is my FastAPI router code. This is the function that returns the list of all comics stored in the database. and my pydantic
How can I get headers or a specific header from my backend API?
I want to retrieve a specific header from my API inside a function with fastAPI, but I can’t found a solution for this. In flask was simply: request.headers[‘your-header-name’] Why the hell with fastAPI is so complicated to do a simple thing like this? Anyone know a solution to retrieve a header? Thanks :) The decorator: I need to read ‘Authorization’
Push live updates through Socket
I need to pass live data from a python script to my server (made with FastApi) and from this server I need to pass all of them to a client (made with Angular). Currently I’m doing Http PUT requests from my script and then I’m using Websocket to pass the updates to the client. The problem is that whenever my
Send / receive in parallel using websockets in Python FastAPI
I will try to explain what I am doing with an example, say I am building a weather client. The browser sends a message over websocket, eg: The server queries the weather every 5 minutes and updates the browser back with the latest data. Now the browser could send another message, eg: Now I the server should STOP updating the
Python + FastAPI + OracleCloud: How to expose my python fastapi endpoint on Oracle Cloud to Internet
I have a Python + FastAPI restful API project running the free tier of Oracle Cloud VM instance. I use Gunicorn to serve the api and also installed Nginx just in case it’s needed. I have tested my running project with curl http://localhost:8000 and I can see my API response. Now my question is : how can I expose this
Fastapi/Tortoise early model init
I have the following implementation with fastapi. My current problem is that I can’t for the life of me do an early init on the tortoise models to get the relationship back in the schema. I’ve tried dumping the following line basically everywhere and it just doesn’t seem to work. i’ve also tried using prefetch_related this way but that doesn’t
HTTPS POST to query FastAPI using python requests
I am trying to serve a Neural Network using FastAPI. The manual site http://localhost:8000/docs#/default/predict_predict_post works fine and translates into the following curl command: which also works. When I try to query the API using python requests: I only get the “422 Unprocessable Entity” Errors. Where am I going wrong here? Answer You provide a data argument to requests.post, which does