diff --git a/docs/source/tour.rst b/docs/source/tour.rst index 962c720..f041e3f 100644 --- a/docs/source/tour.rst +++ b/docs/source/tour.rst @@ -416,6 +416,22 @@ Requests to ``/flask/`` will be handled by Flask. Everything else goes through Responder. Both WSGI and ASGI apps are supported — Responder wraps WSGI apps in an ASGI adapter automatically. +You can also mount `marimo `_ notebooks as +interactive dashboards within your API:: + + import marimo + + server = ( + marimo.create_asgi_app() + .with_app(path="", root="./notebooks/dashboard.py") + .with_app(path="/analysis", root="./notebooks/analysis.py") + ) + + api.mount("/notebooks", server.build()) + +Notebooks are served at ``/notebooks/`` and ``/notebooks/analysis``, +with full interactivity — reactive cells, widgets, plots, and all. + Cookies ------- diff --git a/examples/marimo_mount.py b/examples/marimo_mount.py new file mode 100644 index 0000000..d888a15 --- /dev/null +++ b/examples/marimo_mount.py @@ -0,0 +1,31 @@ +"""Mount marimo notebooks inside a Responder API. + +Requirements: + pip install responder marimo + +Usage: + python examples/marimo_mount.py + +Then visit: + http://127.0.0.1:5042/hello → Responder JSON endpoint + http://127.0.0.1:5042/notebooks/ → Interactive marimo notebook +""" + +import marimo + +import responder + +api = responder.API() + + +@api.route("/hello") +def hello(req, resp): + resp.media = {"message": "Hello from Responder!"} + + +# Mount marimo notebooks at /notebooks +server = marimo.create_asgi_app().with_app(path="", root="notebooks/hello.py") +api.mount("/notebooks", server.build()) + +if __name__ == "__main__": + api.run()