hi
I am trying to call a streamlit file from PHP script. It gets called when I use a port number. But when I make changes to the file and execute it on the port, the changes don’t get updated. I want to clear the contents present in the file and then over write it
Thanks for posting! If you’re doing this locally, I have recorded my screen running an example app with the scenario you provided; updating the Streamlit app and seeing changes propagate to the port.
Directory tree structure:
tester/
│
├── streamlit_app.py # Streamlit app file
└── php_app.php # PHP script to run the Streamlit app
Here’s the code for my .php file;
<?php
// Command to run Streamlit app
$command = 'streamlit run streamlit_app.py';
// Execute the command
$output = shell_exec($command);
// Print the output
echo $output;
?>
Python/Streamlit code;
import streamlit as st
st.title('Hello from Streamlit! 🎈')
st.write('This app is run from PHP!')
code = '''<?php
// Command to run Streamlit app
$command = 'streamlit run streamlit_app.py';
// Execute the command
$output = shell_exec($command);
// Print the output
echo $output;
?>'''
st.code(code, language="php")
if st.button("Click to see baloons!"):
st.balloons()
On the terminal, run php -S localhost:8000 then open a browser window and go to http://localhost:8000/php_app.php. This will execute the PHP code and in turn, run the Streamlit app automatically. If you modify and save the code in your Streamlit app, it should rerun your app now.
Thank you so much for the reply.
I have my majority of code in python in streamlit. I just want to keep the file running and refreshing on the same port. I have my file stored in ‘htdocs’ of XAMPP. Could that possibly be a reason for my config.toml file not being read because I have made changes to the colors but they don’t reflect on the site.
Is there anyway for changing the URL which will be displayed? Like instead of localhost:8501 I want it to display the website I want?
I have hosted the website on a beta server as well but it doesn’t load.
Thanks in advance
Thanks for the info. When you’re running locally and change the theme in .streamlit/config.toml, you have to restart the app again by running streamlit run <you_app_name>.py for the changes to reflect.
I’m not entirely sure you can change the domain but there are possible ways around this like using a reverse proxy (although I haven’t given it a shot, yet) like Nginx or Apache. Here’s a tutorial someone made on deploying Streamlit app with custom domain on Apache 2.