__init__(self, *args, **kwargs) | Initialize the app. |
__repr__(self) -> 'str' | Get the string representation of the app. |
__call__(self) -> 'FastAPI' | Run the backend api instance. |
add_default_endpoints(self) | Add the default endpoints. |
add_cors(self) | Add CORS middleware to the app. |
preprocess(self, state: 'State', event: 'Event') -> 'StateUpdate | None' | Preprocess the event.
This is where middleware can modify the event before it is processed.
Each middleware is called in the order it was added to the app.
If a middleware returns an update, the event is not processed and the
update is returned. |
postprocess(self, state: 'State', event: 'Event', update: 'StateUpdate') -> 'StateUpdate' | Postprocess the event.
This is where middleware can modify the delta after it is processed.
Each middleware is called in the order it was added to the app. |
add_middleware(self, middleware: 'Middleware', index: 'int | None' = None) | Add middleware to the app. |
_generate_component(component: 'Component | ComponentCallable') -> 'Component' | Generate a component from a callable. |
add_page(self, component: 'Component | ComponentCallable', route: 'str | None' = None, title: 'str' = 'Reflex App', description: 'str' = 'A Reflex app.', image='favicon.ico', on_load: 'EventHandler | EventSpec | list[EventHandler | EventSpec] | None' = None, meta: 'list[dict[str, str]]' = [], script_tags: 'list[Component] | None' = None) | Add a page to the app.
If the component is a callable, by default the route is the name of the
function. Otherwise, a route must be provided. |
get_load_events(self, route: 'str') -> 'list[EventHandler | EventSpec]' | Get the load events for a route. |
_check_routes_conflict(self, new_route: 'str') | Verify if there is any conflict between the new route and any existing route.
Based on conflicts that NextJS would throw if not intercepted.
Raises:
ValueError: exception showing which conflict exist with the route to be added |
add_custom_404_page(self, component: 'Component | ComponentCallable | None' = None, title: 'str' = '404 - Not Found', image: 'str' = 'favicon.ico', description: 'str' = 'The page was not found', on_load: 'EventHandler | EventSpec | list[EventHandler | EventSpec] | None' = None, meta: 'list[dict[str, str]]' = []) | Define a custom 404 page for any url having no match.
If there is no page defined on 'index' route, add the 404 page to it.
If there is no global catchall defined, add the 404 page with a catchall |
setup_admin_dash(self) | Setup the admin dash. |
get_frontend_packages(self, imports: 'Dict[str, set[ImportVar]]') | Gets the frontend packages to be installed and filters out the unnecessary ones. |
compile(self) | Compile the app and output it to the pages folder. |
modify_state(self, token: 'str') -> 'AsyncIterator[State]' | Modify the state out of band. |
_process_background(self, state: 'State', event: 'Event') -> 'asyncio.Task | None' | Process an event in the background and emit updates as they arrive. |