Answer the question
In order to leave comments, you need to log in
Why does FastAPI complain about a get request?
I decided to try a new framework for an asynchronous backend in python and ran into an error when getting a request:
TypeError: 'dict_keys' object is not subscriptable
Swears at the get_random function:
class Database:
def __init__(self):
self._items: typing.Dict[int, PhraseOutput] = {}
def get_random(self) -> int:
return random.choice(self._items.keys())
def get(self, id: int) -> typing.Optional[PhraseOutput]:
return self._items.get(id)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question