Questions tagged [starlette]
Questions about Starlette (a lightweight python ASGI framework/toolkit).
starlette
326
questions
0
votes
1
answer
27
views
Get path template from starlette request from a middleware
I am building a middleware to log calls to functions among other things.
I have read about
FastAPI: How to get raw URL path from request?, which suggests to use request.scope.get("route"), ...
0
votes
2
answers
128
views
"Object of type EXAMPLE_TYPE is not JSON serializable" exception thrown when returning a FastAPI response [duplicate]
The design of my system consists of two parts:
There is a FastAPI webserver interface which wraps some core logic
There is a class which contains all of the core logic, let's call it KeyValueStore ...
0
votes
1
answer
64
views
How to integrate uvicorn, FastAPI, Streamlit and Starlette to get App and API in same server/port?
I have a server that runs FastAPI endpoint with uvicorn on port 8080. I need to start a Streamlit application on the same port using other routes than the existing ones used by FastAPI. I can put the ...
1
vote
0
answers
56
views
Why does importing FastAPI TestClient into my PyCharm debugger session take 24 seconds?
Using PyCharm Pro, importing FastAPI TestClient takes 2 seconds in run mode and 23 in debug. I don't know if this is PyCharm, FastAPI, Starlette, or basically where I start to reduce the time.
Here is ...
0
votes
0
answers
36
views
Uvicorn/FastAPI randomly takes several seconds to receive messages [duplicate]
I have a web app that runs an HTML page with JavaScript WebSockets on the frontend, and a FastAPI/Uvicorn backend. Now the JS connects to the backend and sends a message every second. On reception of ...
0
votes
0
answers
164
views
Encountering "Error: Exception in ASGI application" for WebSocket server with FastAPI
Hi I am trying to create a simple WebSocket server and client with python and FastAPI.
When I run the server.py and it receives a message from client.py, the server will throw up the follow stack ...
0
votes
0
answers
31
views
Setting a Cookie for multiple subdomains
I am currently facing a little challenge. I have a FastAPI Backend with a Mongo Database and two Angular Frontends. Both Frontends are communicating with the same Backend since both applications use ...
0
votes
1
answer
58
views
Fastapi's `TestClient`' fails with SSE response
I'm currently doing unit-tests with a fastapi service using pytest. I found that fastapi.testclient.TestClient can only handle one post request and subsequent call to TestClient.post would fail. Here ...
0
votes
1
answer
78
views
How to get requests per second with starlette exporter
How can I get metrics on requests per seconds with the metrics exposed by the starlette exporter (link here). I have a Grafana instance, and have metrics like starlette_requests_total
and ...
0
votes
0
answers
56
views
FastAPI : sqlalchemy.exc.InvalidRequestError: This session is in 'committed' state; no further SQL can be emitted within this transaction
I am using fastapi along with starlette-admin for my project. when I try to delete an file saved entry from starlette-admin table I get the a large error, this is the last line of the same.
...
1
vote
2
answers
121
views
Routing submodule functions using FastAPI's APIRouter
I have the following in my main.py:
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.templating import ...
0
votes
0
answers
130
views
FastAPI+Authlib Error: All connection attempts failed
I am trying to implement login with google in my fastapi application
I am running the fastapi application in K8S cluster:
Here is relevant code:
here is my ingress-nginx config file:
apiVersion: ...
1
vote
0
answers
104
views
How to use await request.form() while allowing validation using Form in FastAPI? [duplicate]
I'm writing a middleware for my FastAPI app to log details of each request.
I understand that await request.form() will get the form data of the request.
But I know this will consume all the data, and ...
1
vote
1
answer
257
views
FastAPI TrustedHostMiddleware refuses my host
When I was developing the application on my local machine and I tried to reach /docs I had to set up up 127.0.0.1 as my trusted host. This worked fine. But now I have put the app on the server and ...
1
vote
1
answer
1k
views
How to force all exceptions to go through a FastAPI middleware?
I am writing an app using the python fastapi library. Parts of my code raise different exceptions which I need to process. I want all that processing to be done in a single place (with different ...