Quite new here. Discovered streamlit a few weeks ago, but I think the app Iām currently working on could be interesting to some of you.
Itās called StreamPy, a streamlit-based python interactive interpreter allowing to run streamlit commands and pop widgets interactively in the consoleās queue. I added a basic text editor to work on longer scripts for convenience.
You can find the repo here or you can try the app here.
Still a work in progress (likely not bug-proof). Any feedback/contribution welcome with gratitude!
Let me know if giving users the possibility to run arbitrary python code from within the webapp may cause security problems. I mean itās no big deal if a silly user destroys the app itself but I donāt mean to introduce vulnerability on your servers. My first guess was that the appās execution environment is sandboxed in a virtual machine so I was not really worriedā¦
Just found a way to remove threads entirely from the app without loosing any feature. Greatly simplifies and increases robustness of the code while avoiding thread-related session_state issues.
Just added the possibility to hide / show past input cells in the consoleās queue.
Also implemented automatic key attribution so that calling twice a widget with same arguments without specifying a key results in two distinct keys/widgets created.
Streamlitās native automatic key management somewhat produced weird results in some cases when using the deferrer.
Somewhat managed to handle sdtin redirection to an input dialog. Only working on local mode obviously.
Allows using built-in python input command, and more generaly handle all python functions requiring keyboard input.
I guess what is needed to make it work in the web app is a custom widget component for inputting text in a blocking way (stopping the streamlitās script execution until the inputted text is returned). I hope itās feasible within the constraints of streamlit runtime though⦠That would be neat !
Proud to announce that stdin redirection now works both in local mode or in the webapp. Created a custom input component for the purpose. It uses firebase to establish a direct communication between the streamlit ābackendā and the js frontend (in a websocket fashion) in such a way that python may access the data returned by the widget instantly, without having to rerun the whole script.
You may therefore use the classic python āinputā command in the console :
txt=input(āEnter text here:ā) #renders an input widget, python waits for its output
print(txt) # access the content returned by the widget immediately and print it.
Next step, implement proper user login via firebase, use it to save user files in cloud storage so that they persist accross various sessions (In the current implementation, accounts and user files are lost whenever the app goes to sleep).
If you think of any other feature I should add to make the most of this app, feel free to share your thoughts here !
I was also thinking about changing the name of the app, āStreampyā already exists as a python library⦠Any ideas ?
Yes, Iāve been working quite a bit on it lately, as much as my job schedule allowsā¦
I indeed am on twitter (https://twitter.com/B4PT0R), though almost invisible there. I created my account only very recently and didnāt post much.
I gratefully accept your proposal to give Streampy a bit more visibility. The app definitely needs some user testing/feedback at this point, notably to set the direction and priority for the next improvements.
Iāll implement proper login and cloud storage via firebase in the next few days, so by the end of the week it should be ready to receive a bit more visits. I also need to make sure my secrets are protected enough to avoid silly users to use the python console to grab them. I realized last week that they just had to run:
import streamlit
st.write(streamlit.secrets)
in the console to get them⦠which was way too easy !
Found a workaround to that unwanted situation by overriding streamlit module directly in sys.modules with a mocking class so that it bans access to the āsecretsā attributes after init.
So yeah, by the week end, it should be good to go viralā¦
Improved security by restricting access to some modules, improved user log in and implemented cloud file storage so that you may access your files/scripts across sessions.