Category : fastapi

I am trying to implement JWT with fastapi. Currently looking at the following libraries fastapi-users FastAPI JWT Auth In both cases, I see Depends() in method parameter. What does Depends do when there is nothing in the parameter? https://github.com/frankie567/fastapi-users/blob/master/fastapi_users/router/auth.py @router.post("/login") async def login( response: Response, credentials: OAuth2PasswordRequestForm = Depends() ): https://indominusbyte.github.io/fastapi-jwt-auth/usage/basic/ @app.post(‘/login’) def login(user: User, ..

Read more

Being very new to FastAPI I am strugling to test slightly more difficult code than I saw in the tutorial. I use fastapi_cache module and Redis like this: from fastapi import Depends, FastAPI, Query, Request from fastapi_cache.backends.redis import CACHE_KEY, RedisCacheBackend from fastapi_cache import caches, close_caches app = FastAPI() def redis_cache(): return caches.get(CACHE_KEY) @app.get(‘/cache’) async def ..

Read more

I’m kinda new to python and FastApi. I’m running some pytests and I’m getting a 422 response instread of a 201. Here’s the code. pizza_type_dict = { ‘name’: ‘Salami Pizza’, ‘price’: 2.50, ‘description’: ‘Italian style’ } def create_sauce_for_pizza_type(): response = client.post( "/v1/sauces", json={"name": "Spicy sauce", "price": 0.5, "description": "good sauce", "stock": 10}, ) assert response.status_code ..

Read more