Open bglgwyng opened 2 months ago
AFAIK reflex should be considered more as framework not as a toolkit or library. Which means: Reflex calls you, not the other way round.
Some concepts might hinder you to "simply" start a server, e.g. state-instrumentation during inheritance, compilation of the frontend, ...
Do we have an official way to achieve it?
I guess no. Maybe you can also look into AppHarness if you really need to run the app programmatically.
Another suggestion: In case you want to run it from within another existing non-reflex project, maybe you can find another link but inclusion such as FastAPI Routes/coupling via DB/... to marry the two.
Not sure what the use case for such functionality would be
If anything, if you really need to launch Reflex from another script, using subprocess.run()
would be the recommended way by the team.
I do something like this when I want to be able to debug from pycharm.
from reflex.reflex import _run
if __name__ == "__main__":
_run()
Obviously, not a good idea for any production case, but I'm not sure what your use case is.
My use case is a bit weird. I need to distribute reflex app in installable format rather than python code thanks to an unconvincing policy. So I'm trying pyInstaller and need to make entry code in .py. Yes, I admit that nobody else is in the same situation.
However, I also belive that, in general sense, the requested functionality is expected to be provided by default.
I do something like this when I want to be able to debug from pycharm.
from reflex.reflex import _run if __name__ == "__main__": _run()
Obviously, not a good idea for any production case, but I'm not sure what your use case is.
I tried it but it didnt work. I'll try again! Thanks.
My use case is a bit weird. I need to distribute reflex app in installable format rather than python code thanks to an unconvincing policy. So I'm trying pyInstaller and need to make entry code in .py. Yes, I admit that nobody else is in the same situation.
However, I also belive that, in general sense, the requested functionality is expected to be provided by default.
You may want to export the app. This command exports the app's both frontend and backend to zip files. You have to figure out how you can start the backend so you interact with it via your front end. https://reflex.dev/docs/api-reference/cli/#export
I'm looking for a way to run a Reflex app programmatically within Python code, rather than using the command line interface. I expect something like
I tried to use
run
function in reflex.py but I haven't made it yet. Do we have an official way to achieve it?