|
|
import streamlit as st |
|
|
|
|
|
|
|
|
st.title("Mini App di Automazione Flussi (Esempio)") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'current_step' not in st.session_state: |
|
|
st.session_state.current_step = 1 |
|
|
if 'user_choice' not in st.session_state: |
|
|
st.session_state.user_choice = None |
|
|
if 'user_input' not in st.session_state: |
|
|
st.session_state.user_input = "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if st.session_state.current_step == 1: |
|
|
st.header("Passo 1: Scegli l'azione") |
|
|
options = ["Seleziona...", "Elabora Testo", "Inserisci Dati"] |
|
|
choice = st.selectbox("Che tipo di operazione vuoi simulare?", options) |
|
|
|
|
|
git clone https://huggingface.co/spaces/TATUMAi/README |
|
|
import streamlit as st |
|
|
|
|
|
x = st.slider('Select a value') |
|
|
st.write(x, 'squared is', x * x) |
|
|
git add app.py && git commit -m 'Add application file' && git push |
|
|
if choice != "Seleziona...": |
|
|
if st.button("Vai al Passo 2"): |
|
|
st.session_state.user_choice = choice |
|
|
st.session_state.current_step = 2 |
|
|
st.rerun() |
|
|
|
|
|
|
|
|
elif st.session_state.current_step == 2: |
|
|
st.header(f"Passo 2: {st.session_state.user_choice}") |
|
|
|
|
|
if st.session_state.user_choice == "Elabora Testo": |
|
|
text = st.text_area("Inserisci il testo da elaborare:") |
|
|
operation = st.radio("Scegli operazione:", ["Conta Parole", "Converti in Maiuscolo"]) |
|
|
|
|
|
if st.button("Esegui e Vai al Riepilogo"): |
|
|
if operation == "Conta Parole": |
|
|
result = f"Il testo contiene {len(text.split())} parole." |
|
|
elif operation == "Converti in Maiuscolo": |
|
|
result = text.upper() |
|
|
else: |
|
|
result = "Operazione non valida." |
|
|
|
|
|
st.session_state.user_input = text |
|
|
st.session_state.result = result |
|
|
st.session_state.current_step = 3 |
|
|
st.rerun() |
|
|
|
|
|
elif st.session_state.user_choice == "Inserisci Dati": |
|
|
name = st.text_input("Nome:") |
|
|
email = st.text_input("Email:") |
|
|
|
|
|
if st.button("Salva e Vai al Riepilogo"): |
|
|
result = f"Dati inseriti: Nome={name}, Email={email}" |
|
|
st.session_state.user_input = f"Nome: {name}\nEmail: {email}" |
|
|
st.session_state.result = result |
|
|
st.session_state.current_step = 3 |
|
|
st.rerun() |
|
|
|
|
|
|
|
|
if st.button("Torna al Passo 1"): |
|
|
st.session_state.current_step = 1 |
|
|
st.session_state.user_choice = None |
|
|
st.session_state.user_input = "" |
|
|
st.session_state.result = "" |
|
|
st.rerun() |
|
|
|
|
|
|
|
|
|
|
|
elif st.session_state.current_step == 3: |
|
|
st.header("Passo 3: Riepilogo Flusso") |
|
|
st.write(f"Azione scelta: {st.session_state.user_choice}") |
|
|
st.subheader("Input fornito:") |
|
|
st.text(st.session_state.user_input) |
|
|
st.subheader("Risultato:") |
|
|
st.success(st.session_state.result) |
|
|
|
|
|
if st.button("Ricomincia Flusso"): |
|
|
|
|
|
st.session_state.current_step = 1 |
|
|
st.session_state.user_choice = None |
|
|
st.session_state.user_input = "" |
|
|
st.session_state.result = "" |
|
|
st.rerun() |
|
|
|
|
|
|
|
|
st.sidebar.info(f"Stato attuale: Passo {st.session_state.current_step}") |
|
|
if st.session_state.user_choice: |
|
|
st.sidebar.write(f"Azione: {st.session_state.user_choice}") |
|
|
|
|
|
|