How to send a plain text response? #210
-
The client for the following method requires plain text response and the content type to be set to "text/plain". I cannot find a way of doing both with FastHTML. The following returns the correct content type, but wraps the string in a HTML page. @rt('/quine/{name}')
def options(name: str):
return "dav: 1", HttpHeader("content-type", "text/plain") If I remove the HTTP header, it sets the content type to "text/html", but returns the raw string. @rt('/quine/{name}')
def options(name: str):
return "dav: 1" The client for this application considers both of these to be failure cases. Here, it means WebDAV is not supported by the server. |
Beta Was this translation helpful? Give feedback.
Answered by
JosephKiranBabu
Aug 6, 2024
Replies: 1 comment
-
Found the answer in FastAPI documentation. @rt('/quine/{name}')
def options(name: str):
return Response("dav: 1", media_type="text/plain") |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
JosephKiranBabu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found the answer in FastAPI documentation.