File size: 1,587 Bytes
d4abf6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Required packages importing
import os, streamlit as st
from streamlit_option_menu import option_menu

st.set_page_config(layout="wide")

hide_streamlit_style = """
            <style>
            #MainMenu {visibility: hidden;}
            footer {visibility: hidden;}
            </style>
            """
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
filename = './/autogen//files//_configmap.tpl'

def streamlit_menu():
    # sidebar menu
    with st.sidebar:
        selected = option_menu(
            menu_title="Main Menu",  # required
            options=["Search"],  # required
            icons=["search"],  # optional
            menu_icon="cast",  # optional
            default_index=0,  # optional
        )
    return selected

selected = streamlit_menu()

if selected == "Search":
    st.markdown(""" Message replacement in configmap files""")

    expander = st.expander("See explanation")
    expander.write("""
        This tool replaces msg1 & msg2 values in the _configmap.tpl \n
    """)
    with st.expander('Demo'):
        st.image('demo.png')       
         
    msg1 = st.text_input('MSG1', '')
    msg2 = st.text_area("MSG2")
    
    if st.button('Submit'):
        # Read in the file
        with open(filename, 'r') as file :
            filedata = file.read()

        # Replace the target string
        filedata = filedata.replace('$msg1', msg1)
        filedata = filedata.replace('$msg2', msg2)

        # Write the file out again
        with open(filename, 'w') as file:
            file.write(filedata)
        
        st.balloons()