Python: FastAPI error 422 with post request

I'm building a simple API to test a database. When I use get request everything works fine, but if I change to post I get "unprocessable entity" error: Here is FastAPI code: from fastapi import...

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, not client remote IP. My...

does fastapi contrib has paginator for postgresql?

I read the fastapi contrib code. Pagination available for mongodb only. Does fastapi has pagination module for postgres db also?

Debug FastAPI application in VSCode

i'm trying to debug an application (a web api) that use FastAPI (uvicorn) I'm also using poetry and set the projev virtual environment in vscode. i read this tutorial to setup uvicorn and this one...

FastAPI docs not working with nginx Ingress controller

I have written an application that runs a FastAPI server inside a Kubernetes pod. The external communication with the pod goes through an nginx ingress controller in a separate pod. I am running...

CSS not recognized when served with FastAPI

I have a FastAPI app built and an index, css and js file that work when opened directly, but I can't get the css file to show up when being served with FastAPI. I've tried troubleshooting in case...

FastAPI SQLAlchemy relationship models loading

I'm starting with FastAPI and SQLAlchemy, and I have a question about loading models in the correct order to satisfy SQLAlchemy models relationship. I've got two models, Profile and...

pydantic BaseModel not found in Fastapi

I have [tag:python3] 3.6.9 on Kubuntu 18.04. I have installed [tag:fastapi] using pip3 install fastapi. I'm trying to test drive the framework through its official documentation and I'm in the...

List of object attributes in pydantic model

I use Fast API to create a web service. There are following sqlAlchemy models: class User(Base): __tablename__ = 'user' account_name = Column(String, primary_key=True, index=True,...

How can I run the fast-api server using Pycharm?

I have a simple API function as below, from fastapi import FastAPI app = FastAPI() @app.get("/") async def read_root(): return {"Hello": "World"} I am starting the server using uvicorn...

How to capture arbitrary paths at one route in FastAPI?

I'm serving React app from FastAPI by mounting app.mount("/static", StaticFiles(directory="static"), name="static") @app.route('/session') async def renderReactApp(request: Request): return...

FastAPI / Pydantic circular references in separate files

I would love to use a schema that looks something like the following in FastAPI: from __future__ import annotations from typing import List from pydantic import BaseModel class...

How to create routes with FastAPI within a class

So I need to have some routes inside a class, but the route methods need to have the self attr (to access the class' attributes). However, FastAPI then assumes self is its own required argument...

Fetch in JavaScript for FastApi in localhost

How can you use my Api made with FastAPI, from my localhost, from an external html, for example, it is my simple implementation of test: main.py: from fastapi import FastAPI app =...

Get starlette request body in the middleware context

I have such middleware class RequestContext(BaseHTTPMiddleware): async def dispatch(self, request: Request, call_next: RequestResponseEndpoint): request_id =...

How to use nested pydantic models for sqlalchemy in a flexible way

from fastapi import Depends, FastAPI, HTTPException, Body, Request from sqlalchemy import create_engine, Boolean, Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import...

FastAPI - Supporting multiple authentication dependencies

Problem I currently have JWT dependency named jwt which makes sure it passes JWT authentication stage before hitting the endpoint like this: sample_endpoint.py: from fastapi import APIRouter,...

Python uvicorn : The term 'uvicorn' is not recognized as the name of a cmdlet, function, script file

Good evening, I am using python 3.9 and try to run a new FastAPI service on Windows 10 Pro based on the documentation on internet https://www.uvicorn.org/ i executed the following statements pip...

Apple M1: install psycopg2 package Symbol not found: _PQbackendPID

pg_config venv ❯ which pg_config /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config pip3 install -r requirements.txt requirements.txt venv ❯ cat requirements.txt -i...

Replace server name with fake server name in response header in fastapi

I am using uvicorn as server to run app using fast api. While executing endpoint url in Swagger, following message is shown in response header of server response. content-length: 122 ...

How to set "/*" path to capture all routes in FastAPI?

Like in ExpressJS, app.get("/*") works for all routes. My code - from typing import Optional from fastapi import FastAPI app = FastAPI() @app.get('/*') def user_lost(): return "Sorry You...

AWS Lambda function using CognitoIdentityServiceProvider's adminCreateUser method is failing all of a sudden

In the past few days I've been testing a certain flow using AWS Lambda functions and my lambda function that gets triggered after a pre-sign up in the Cognito User pool was working fine and...

sqlalchemy Session object has no attribute add

I am trying to insert the data to mysql server, While doing so when i try to add the data into the SQLalchemy sesion i am getting the error "Generator object has no attribute add" db=get_db() temp...

Can I generate dynamic apiKey using FastAPI

I am creating API for machine learning models using FastAPI. I need to secure my endpoints. I am currently using apiKey for authentication. I implemented authentication following this link: So far...

InvalidRequestError: Could not evaluate current criteria in Python: "Cannot evaluate Select". Specify 'fetch' or False for the synchronize_session

have this error when try run this code: query = delete(BannerLocalization).where( BannerLocalization.locale == locale, BannerLocalization.id == pk, ...

Display Dataframe as FastAPI output

Dear Community Members, I am new to FastAPI and I am trying to display the pandas dataframe as FastAPI output but I am not able to get the desired result. Here is something I am have done: from...

Setting favicon for fastapi?

I know how to set a favicon for a html page. I was wondering if it is possible to set a favicon for all "pages" from my fastapi project? So when I do post and get requests in a browser, a favicon...

FastAPI with nginx does not serve static files in HTTPS

I have a small, test FastAPI web application that is serving a simple HTML page that requires a css style sheet located in the static folder. It is installed on a Linode server (Ubuntu 20.04...

How to run FastAPI app on multiple ports?

I have a FastAPI application that I am running on port 30000 using Uvicorn programmatically. Now I want to run the same application on port 8443 too. The same application needs to run on both...

Getting DLL error when running tensorflow/keras program on python gpu 3.8

I am trying to run my simple AI program but I keep getting this DLL error: ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a...