allow TypedDict as a response value

This commit is contained in:
Matthijs van der Vleuten 2022-07-14 11:22:22 +02:00 committed by David Lord
parent 76a6b4f2b5
commit 4bf7415a96
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 15 additions and 1 deletions

View file

@ -3,6 +3,8 @@ from __future__ import annotations
import typing as t
from http import HTTPStatus
import typing_extensions as te
from flask import Flask
from flask import jsonify
from flask import stream_template
@ -38,6 +40,15 @@ def hello_json_list() -> t.List[t.Any]:
return [{"message": "Hello"}, {"message": "World"}]
class StatusJSON(te.TypedDict):
status: str
@app.route("/typed-dict")
def typed_dict() -> StatusJSON:
return {"status": "ok"}
@app.route("/generator")
def hello_generator() -> t.Generator[str, None, None]:
def show() -> t.Generator[str, None, None]: