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
1
vote
1 answer

Serve React build files from two different static build directories

I am currently in the process of creating a react webpage, using starlette as my web server framework that hooks up my database and provides the API. To improve code separation and unneeded loading of files I divided my page into two separately…
1
vote
0 answers

coroutine object is not JSON serializable

I am new to async python. I have created a singleton object that supposed to load files from the filesystem class AppResourceLoader(metaclass=Singleton): async def load_yaml(self, resource_filepath): async with…
lapots
  • 12,553
  • 32
  • 121
  • 242
1
vote
1 answer

How do I return an element with FastAPI

I am trying to find a way to insert an image using FastAPI, this is my code: app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"] ) @app.get("/files/{file_path:path}") def…
RalphCh97
  • 61
  • 9
1
vote
0 answers

'oauth.google.authorize_redirect()' returns Error 500 : 'httpx.exceptions.ConnectTimeout'

I'm actually working on a platform using starlette framework with authlib for Google OAuth authentification. Since today, I get a 500 Internal Server Error when calling oauth.google.authorize_redirect(request, redirect_uri) with error…
bask
  • 11
  • 1
1
vote
1 answer

SSL implementation with starlette in Docker

I have some app, writhed on Python 3.7, that runs on ASGI and Starlette. I need app to accept only HTTP requests. I've opened ports 443 and 80 via docker-compose and add HTTPSRedirectMiddleware to ensure that all connections will be redirected to…
Stasello Boldirev
  • 123
  • 1
  • 2
  • 7
1
vote
0 answers

Write image to folder after POST request

I'm trying to send two images to my API and then write them to a folder. However when I try to save the image, I get the following error: AttributeError: type object 'Image' has no attribute 'fromarray' This is my API function that should receive…
vftw
  • 1,547
  • 3
  • 22
  • 51
0
votes
1 answer

receive_nowait raise WouldBlock error while uploading multiple files in FastAPI

I am trying to send multiple files from UI to fastAPI in formData. But the API is throwing error instantly when the API's is triggered. async def createNewDirectory(files: Optional[List[UploadFile]] = File(None), content: list = [], db:…
0
votes
0 answers

FastAPI acync BackgroundTask blocks main event loop

I have a FastAPI asynchronous task that I would like to run after returning from an endpoint. To do this, I am using BackgroundTasks; however, it seems that whilst the background task is running the main event loop is blocked. async def…
Rookleton
  • 11
  • 2
0
votes
0 answers

How to make BackgroundTasks manager?

I have FastAPI endpoint to upload csv files to mongodb: Router endpoint: @UploadRouter.post( "/", response_model=CsvUploadResponse, status_code=status.HTTP_201_CREATED ) async def upload( bg:BackgroundTasks, file : UploadFile =…
beetard
  • 1
  • 1
0
votes
1 answer

FastApi (Starlette) + NGINX Proxy: URL scheme in Request Object not correct?

I'd like to know the following How does Starlette set the "url" property in the Request object - especially when operated behind a NGINX proxy. How can request.url be manipulated on the NGINX level -- setting proxy headers doesn't modify it at…
physicus
  • 361
  • 4
  • 12
0
votes
0 answers

Fast API and Netlify CORS issue

I am using netlify for frontend and fastapi in the backend which is hosted in deta space. My front end is running from "https://actuallyinflint.netlify.app" but I have custom dns for "https://actuallyinflint.com" However I keep getting the cors…
thatonenerd
  • 134
  • 2
  • 13
0
votes
0 answers

uploading list of object, where object will be having file and metadata field in FastAPI

In my fastAPI application, i am defining a post api, where i have to receive files and its metadata from frontend. I will be receiving list of dictionary(or object) where dictionary will be having two field file and metadata. But i am getting error…
Jitaso
  • 1
  • 1
0
votes
0 answers

How can I logging StremingRespone in Fastapi with out error?

import logging import time import json from typing import Callable from uuid import uuid4 from fastapi import FastAPI, Request, Response from starlette.middleware.base import BaseHTTPMiddleware from starlette.types import Message from…
NAM
  • 3
  • 3
0
votes
0 answers

Avoiding API Gateway 504 timeouts with FastAPI, BackgroundTasks (Starlette, Mangum)

I have setup a FastAPI REST API with AWS Gateway and trying to make use of the BackgroundTasks feature where I can do some work, create a unique token, schedule a background task and return immediately back to the client (which works great locally…
0
votes
1 answer

Custom FastAPI middleware causes LocalProtocolError("Too much data for declared Content-Length") exception

I have a middleware implemented for FastAPI. For responses that includes some content, it works perfectly. But if a response has no body, it is causing LocalProtocolError("Too much data for declared Content-Length") exception. To isolate the…
SercioSoydanov
  • 980
  • 10
  • 29