reactpy
reactpy copied to clipboard
ReactPy ASGI Middleware and standalone ReactPy ASGI App
Issues
- fix #1110
Solution
Create a ReactPy ASGI application that can also function as middleware.
Features of the ASGI application/middleware
- Gain compatibility with every ASGI framework.
- Allows ReactPy to be "self contained" if needed (run within any ASGI webserver without a backend).
- Allows ReactPy to auto-serve web modules.
Things to deprecate:
reactpy.backend.*.configureis no longer needed.
Checklist
- [ ] Tests have been included for all bug fixes or added functionality.
- [ ] The
changelog.rsthas been updated with any significant changes.
The more I develop this, the more I realize it's unwise to finish this PR until the following issues are closed
- #1079
- #653
This PR is in a 90% finished state, but I will hold off on finishing it for now and refocus on template tags.
@rmorshea I will implement things using starlette for static files now, but ideally I don't want a web framework to be a dependency for us.
I would feel more comfortable using whitenoise as it's a static-file focused library that doesn't have extra stuff. However, this relies on this PR getting merged:
- https://github.com/evansd/whitenoise/pull/359
Note to self:
It seems logical to mandate that ReactPy standalone's root component must be a html.html node. By forcing the user to template the whole page, this would eliminate the need for a janky Options(head=...) parameter.
html.html(
{"lang": "en"},
html.head(
...,
),
html.body(
...,
),
)
It also seems logical to have ReactPyStandalone and ReactPyMiddleware to be discrete classes.
The whitenoise maintainers have largely been MIA, so I went ahead and forked it into my own package ServeStatic.
This PR is no longer blocked.