- 
                Notifications
    You must be signed in to change notification settings 
- Fork 749
example: shiny py-shiny #5998
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
base: main
Are you sure you want to change the base?
example: shiny py-shiny #5998
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,86 @@ | ||||||||
| # /// script | ||||||||
| # requires-python = ">=3.12" | ||||||||
| # dependencies = [ | ||||||||
| # "shiny", | ||||||||
| # "marimo", | ||||||||
| # "vega-datasets==0.9.0", | ||||||||
| # ] | ||||||||
| # /// | ||||||||
| from shiny import App, render, ui | ||||||||
| from htmltools import HTML | ||||||||
| import marimo | ||||||||
| import os | ||||||||
| from starlette.middleware.wsgi import WSGIMiddleware | ||||||||
| from starlette.applications import Starlette | ||||||||
| from starlette.routing import Mount, Route | ||||||||
| from starlette.responses import RedirectResponse | ||||||||
|  | ||||||||
|  | ||||||||
| ui_dir = os.path.join(os.path.dirname(__file__), "..", "..", "ui") | ||||||||
| templates_dir = os.path.join(os.path.dirname(__file__), "templates") | ||||||||
|  | ||||||||
| marimo_app = marimo.create_asgi_app() | ||||||||
| app_names: list[str] = [] | ||||||||
|  | ||||||||
| for filename in sorted(os.listdir(ui_dir)): | ||||||||
| if filename.endswith(".py"): | ||||||||
| app_name = os.path.splitext(filename)[0] | ||||||||
| app_path = os.path.join(ui_dir, filename) | ||||||||
| marimo_app = marimo_app.with_app(path=f"/{app_name}", root=app_path) | ||||||||
| app_names.append(app_name) | ||||||||
|  | ||||||||
| shiny_ui = ui.page_fluid(ui.output_ui("_html")) | ||||||||
|  | ||||||||
|  | ||||||||
| def shiny_server(input, output, session): | ||||||||
| @render.text | ||||||||
| def _html(): | ||||||||
| subdiv = [] | ||||||||
| for name in app_names: | ||||||||
| subdiv.append( | ||||||||
| f""" | ||||||||
| <div class="bg-base-200 rounded-lg shadow-md hover:shadow-xl | ||||||||
| transition-shadow duration-300 w-64"> | ||||||||
| <a href="/{name}" target="_blank" class="block w-full h-full"> | ||||||||
| <div class="p-4"> | ||||||||
| <h2 class="text-xl font-semibold mb-2">{name}</h2> | ||||||||
| <p class="text-sm text-gray-500">Click to open app</p> | ||||||||
| </div> | ||||||||
| </a> | ||||||||
| </div> | ||||||||
| """ | ||||||||
| ) | ||||||||
| head = """ | ||||||||
| <head> | ||||||||
| <script src="https://cdn.tailwindcss.com" /> | ||||||||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/full.min.css" | ||||||||
| <title>Marimo apps in Shiny</title> | ||||||||
| </head> | ||||||||
| """ | ||||||||
|          | ||||||||
| body = f""" | ||||||||
| <body> | ||||||||
|          | ||||||||
| <body> | 
        
          
              
                Outdated
          
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| </body> | |
| </body> | 
| </body> | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your review.
For now, script nor more works.
I'll try again tomorrow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.