Spaces:
Runtime error
Runtime error
onesolution9983
commited on
Commit
•
d4abf6b
1
Parent(s):
b702bc3
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Required packages importing
|
2 |
+
import os, streamlit as st
|
3 |
+
from streamlit_option_menu import option_menu
|
4 |
+
|
5 |
+
st.set_page_config(layout="wide")
|
6 |
+
|
7 |
+
hide_streamlit_style = """
|
8 |
+
<style>
|
9 |
+
#MainMenu {visibility: hidden;}
|
10 |
+
footer {visibility: hidden;}
|
11 |
+
</style>
|
12 |
+
"""
|
13 |
+
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
14 |
+
filename = './/autogen//files//_configmap.tpl'
|
15 |
+
|
16 |
+
def streamlit_menu():
|
17 |
+
# sidebar menu
|
18 |
+
with st.sidebar:
|
19 |
+
selected = option_menu(
|
20 |
+
menu_title="Main Menu", # required
|
21 |
+
options=["Search"], # required
|
22 |
+
icons=["search"], # optional
|
23 |
+
menu_icon="cast", # optional
|
24 |
+
default_index=0, # optional
|
25 |
+
)
|
26 |
+
return selected
|
27 |
+
|
28 |
+
selected = streamlit_menu()
|
29 |
+
|
30 |
+
if selected == "Search":
|
31 |
+
st.markdown(""" Message replacement in configmap files""")
|
32 |
+
|
33 |
+
expander = st.expander("See explanation")
|
34 |
+
expander.write("""
|
35 |
+
This tool replaces msg1 & msg2 values in the _configmap.tpl \n
|
36 |
+
""")
|
37 |
+
with st.expander('Demo'):
|
38 |
+
st.image('demo.png')
|
39 |
+
|
40 |
+
msg1 = st.text_input('MSG1', '')
|
41 |
+
msg2 = st.text_area("MSG2")
|
42 |
+
|
43 |
+
if st.button('Submit'):
|
44 |
+
# Read in the file
|
45 |
+
with open(filename, 'r') as file :
|
46 |
+
filedata = file.read()
|
47 |
+
|
48 |
+
# Replace the target string
|
49 |
+
filedata = filedata.replace('$msg1', msg1)
|
50 |
+
filedata = filedata.replace('$msg2', msg2)
|
51 |
+
|
52 |
+
# Write the file out again
|
53 |
+
with open(filename, 'w') as file:
|
54 |
+
file.write(filedata)
|
55 |
+
|
56 |
+
st.balloons()
|