12
Browse files- app/app.py +23 -0
app/app.py
CHANGED
|
@@ -17,6 +17,13 @@ def generate_samples():
|
|
| 17 |
subprocess.run(["python", "sample.py", "--out_dir=out-shakespeare-char", "--device=cpu"])
|
| 18 |
st.text("Génération d'échantillons terminée.")
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
def main():
|
| 21 |
st.title("Application de Commandes")
|
| 22 |
|
|
@@ -29,5 +36,21 @@ def main():
|
|
| 29 |
if st.button("Générer des échantillons"):
|
| 30 |
generate_samples()
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if __name__ == "__main__":
|
| 33 |
main()
|
|
|
|
| 17 |
subprocess.run(["python", "sample.py", "--out_dir=out-shakespeare-char", "--device=cpu"])
|
| 18 |
st.text("Génération d'échantillons terminée.")
|
| 19 |
|
| 20 |
+
def run_command(command):
|
| 21 |
+
try:
|
| 22 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, text=True)
|
| 23 |
+
return result.stdout, result.stderr
|
| 24 |
+
except Exception as e:
|
| 25 |
+
return None, str(e)
|
| 26 |
+
|
| 27 |
def main():
|
| 28 |
st.title("Application de Commandes")
|
| 29 |
|
|
|
|
| 36 |
if st.button("Générer des échantillons"):
|
| 37 |
generate_samples()
|
| 38 |
|
| 39 |
+
st.title("Sortie de la commande Python dans Streamlit")
|
| 40 |
+
|
| 41 |
+
# Commande Python que vous souhaitez exécuter
|
| 42 |
+
command = "python sample.py --out_dir=out-shakespeare-char" # Remplacez par votre propre commande
|
| 43 |
+
|
| 44 |
+
# Exécutez la commande et obtenez la sortie
|
| 45 |
+
stdout, stderr = run_command(command)
|
| 46 |
+
|
| 47 |
+
# Affichez la sortie dans Streamlit
|
| 48 |
+
st.subheader("Sortie standard (stdout) :")
|
| 49 |
+
st.code(stdout)
|
| 50 |
+
|
| 51 |
+
st.subheader("Sortie d'erreur (stderr) :")
|
| 52 |
+
st.code(stderr)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
if __name__ == "__main__":
|
| 56 |
main()
|