reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Embedding Pynecone in other apps

Open EgosOwn opened this issue 2 years ago β€’ 7 comments

One of the issues i had with streamlit (from what i remember) is that you can't easily embed streamlit into existing applications, and the same seems to be true here.

It would be really cool if i could do pynecone.run() from an existing app and bind state to existing modules. It would allow one to take existing APIs and wire them up quickly to a pyonecone GUI.

I know that is certainly easier said than done. Go ahead and close this issue if that is too far out of scope or isn't feasible.

Thank you for your efforts, pynecone is neat.

EgosOwn avatar Dec 09 '22 20:12 EgosOwn

This isn't on our roadmap currently, but is a really interesting use case. We will think about how we can incorporate this in the future. Thanks for checking us out!

picklelo avatar Dec 10 '22 02:12 picklelo

Yeah really cool suggestion there may be some ways to do this, we'll brainstorm

Alek99 avatar Dec 10 '22 02:12 Alek99

Since pynecone uses FastAPI, it would be useful if it could support patterns via sub applications.

Something like:

pc_app = pc.App(state=State)

app = FastAPI()
app.mount("/pynecone", pc_app)

chapman73 avatar Dec 10 '22 04:12 chapman73

Ah I see, this is an interesting idea. I'm not too familiar with sub application feature but Ill take get back about this! Thanks for the suggestion

Alek99 avatar Dec 10 '22 04:12 Alek99

Just dropping a thought here. There's no admin interface on FastAPI, so Pynecone could have a useful application in developing what amount to admin/support interfaces. For example, if you built an API, but you want something like Django-style admin abilities, you could build that pretty easily (I imagine) in Pynecone if it were a supported use case.

kkinder avatar Dec 10 '22 10:12 kkinder

my 2c: I have couple of 'utility apps' running on our k8s cluster at work - these apps are mainly for internal use (one form for QA to run periodic tasks manually on testing environment, or some UIs to help with on-call duty). They are usually "single form apps", just do one thing. the stack we use for this is fastapi, installed as a helm chart. the only thing that is "hard" or "icky" to do in these apps is the UI.

so being able to do app.mount("/pynecone", pc_app) would be a game changer, really!

jerguslejko avatar Jan 12 '23 10:01 jerguslejko

That makes a lot of sense, it would be great to combine all these "microapps" together into a single service rather than hosting each one separately. We're seeing a similar use case with our website as we're trying to add a blog subapp to it, but we want to host it along with our main docs site.

We will definitely look into this soon!

picklelo avatar Jan 12 '23 18:01 picklelo