Questions tagged [starlette]

Questions about Starlette (a lightweight python ASGI framework/toolkit).

Starlette is a lightweight ASGI framework/toolkit, which is ideal for building high performance asyncio services.

https://www.starlette.io

259 questions
0
votes
1 answer

How to make logstash listen to a specific port where the python application is running

I am trying to make the logstash pipeline to listen to port 8003 where i am running my python starlette application.I need to collect the logs and pass it to the elastic db. My logstash.conf file is input { udp { type => "logs" port =>…
psp
  • 13
  • 5
0
votes
0 answers

Why does FastAPI APP unreliably send error output "Failed to fetch. Possible Reasons:"?

I created a simple FastAPI app. Sometimes the API call works, but other times it gives a random error message. Here is a minimum reproducible code: from fastapi import FastAPI import uvicorn import time from loguru import logger import…
raghavsikaria
  • 867
  • 17
  • 30
0
votes
0 answers

Fastapi how to add variable to all router with TemplateResponse

I use JinjaTemplate and return data to html this way @router.get('/', response_class=HTMLResponse) async def main_page(request: Request, members: List = [e.value for e in MembersQuantity], activity_service:…
Jekson
  • 2,892
  • 8
  • 44
  • 79
0
votes
0 answers

extract body from starlette response

I want to extract response that is returned by starlette. I was expecting it to similar to request but it is not instead the response is hidden very deep inside Iterator --> frame --> protected_values --> _frame --> 0 --> "response body i…
dev
  • 732
  • 2
  • 8
  • 29
0
votes
1 answer

make fastapi middleware returning custom http status instead of AuthenticationError status 400

In the following example when you pass a username in the basic auth field it raise a basic 400 error, but i want to return 401 since it's related to the authentication system. I did tried Fastapi exceptions classes but they do not raise (i presume…
Bastien B
  • 1,018
  • 8
  • 25
0
votes
1 answer

This Starlette Code works but only with GET, and I need POST

I was able to build from a sample Starlette example a piece of code that gets Basic Auth username and password, reads a header, and grabs the json body. But it only does so if I use "GET" instead of post, and I have not been able to figure out how…
0
votes
1 answer

sys:1: RuntimeWarning: coroutine "FOO" was never awaited

I have the below code using FastAPI and when I try to provide an image to this function, it gives me this traceback on the API result: Traceback (most recent call last): File \"/home/shady/Desktop/BTS/Segmentation/server/fast_app.py\", line 32, in…
Deshwal
  • 3,436
  • 4
  • 35
  • 94
0
votes
1 answer

Why does multiprocessing not get response for API in correct time?

I have an API setup written in FastAPI and I am hitting 1 endpoint using multiprocessing via 5 processes. Here is the reproducible setup: API SETUP (please note this is NOT AN ASYNC API -> nothing is being awaited) import uvicorn from fastapi import…
raghavsikaria
  • 867
  • 17
  • 30
0
votes
0 answers

TypeError: 'list' object is not callable in fastapi

While retrieving the query from database i am getting the list object is not iteratable my python file is from schemas import PersonDetail from mysqlx import Statement from starlette.requests import Request from starlette.responses import…
SPMK
  • 19
  • 5
0
votes
0 answers

sqlite3.OperationalError: no such table: PersonDetail while using starlette fastapi

table is found but still getting the table not found error where my main file is main.py import uvicorn from starlette.applications import Starlette from starlette.routing import Route from API.get import GetMethod from API.post import…
SPMK
  • 19
  • 5
0
votes
0 answers

"sqlalchemy.exc.ArgumentError: Column expression or FROM clause expected " issue in starlette

I got the below error "sqlalchemy.exc.ArgumentError: Column expression or FROM clause expected, got ." My get.py is from tkinter.tix import Select from starlette.requests import Request from starlette.responses import…
SPMK
  • 19
  • 5
0
votes
0 answers

starlette doesn't appear to run requests concurrently

I am using a simple demo Starlette app (right out of the docs, just added an asyncio.sleep() statement there: import asyncio from starlette.applications import Starlette from starlette.responses import JSONResponse from starlette.routing import…
sagism
  • 881
  • 4
  • 11
  • 18
0
votes
1 answer

How to use Starlette and pydantic together

I am trying to use Pydantic to get user value in my Starlette application. How do i do so ? class Post(BaseModel): title:str content:str @app.route("/createposts",methods=["POST"]) async def create_posts(request): data = await request.json() …
Suyog Subedi
  • 1
  • 1
  • 1
0
votes
1 answer

Starlette - storing auth status in session?

Is it okay / safe to keep the authentication result in Starlette session? Example: @app.get("/login") async def login(request: Request): # ...assuming verifying user went ok request.session['logged_in_user'] = user.email # THIS LINE …
tikej
  • 179
  • 1
  • 16
0
votes
1 answer

Sending Notifications to certain clients using Server Sent Events in FastApi?

I have been working with server sent events to send out certain type of notifications to only certain clients. I am using the module called sse-starlette to try and achieve this. I am fairly new to FastApi so I am not able to figure out how to send…
otaku_weeb
  • 107
  • 10