This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import json | |
| from datetime import datetime | |
| from fasthtml.common import * | |
| from fasthtml.starlette import StreamingResponse | |
| from fasthtml.core import to_xml | |
| from datastar_py.sse import SSE_HEADERS, ServerSentEventGenerator | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fasthtml.common import * | |
| # Create middleware to handle requests ending in .json | |
| class JSONRedirectMiddleware(MiddlewareBase): | |
| def __init__(self, app): | |
| self.app = app | |
| # pass along the request with the application/json header | |
| # if the route excepts it (as defined below, the response will be JSON) |