Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactPy ASGI Middleware and standalone ReactPy ASGI App #1113

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

Archmonger
Copy link
Contributor

@Archmonger Archmonger commented Jul 18, 2023

Issues

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.*.configure is no longer needed.

Checklist

  • Tests have been included for all bug fixes or added functionality.
  • The changelog.rst has been updated with any significant changes.

@Archmonger
Copy link
Contributor Author

Archmonger commented Jul 18, 2023

The more I develop this, the more I realize it's unwise to finish this PR until the following issues are closed

This PR is in a 90% finished state, but I will hold off on finishing it for now and refocus on template tags.

@Archmonger Archmonger added the flag-blocked Currently cannot be resolved. label Jul 18, 2023
@Archmonger Archmonger changed the title ASGI Middleware ReactPy ASGI Application & Middleware Jul 18, 2023
@Archmonger
Copy link
Contributor Author

Archmonger commented Jul 20, 2023

@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:

@Archmonger
Copy link
Contributor Author

Archmonger commented Aug 27, 2023

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.

@Archmonger Archmonger changed the title ReactPy ASGI Application & Middleware Rewrite ReactPy as ASGI Middleware, and create a discrete ASGI App Nov 27, 2023
@Archmonger Archmonger changed the title Rewrite ReactPy as ASGI Middleware, and create a discrete ASGI App ReactPy ASGI Middleware and standalone ReactPy ASGI App Feb 21, 2024
@Archmonger
Copy link
Contributor Author

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.

@Archmonger Archmonger removed the flag-blocked Currently cannot be resolved. label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReactPy ASGI App and Middleware
1 participant