Spaces:
Running
Running
import streamlit as st | |
import subprocess | |
def install_package(package_name): | |
command = f"pip install {package_name}" | |
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) | |
for line in process.stdout: | |
st.text(line.rstrip()) | |
process.wait() | |
def main(): | |
st.title("Пакетный менеджер") | |
package_input = st.text_input("Введите имя пакета для установки") | |
if st.button("Установить"): | |
st.text(f"Выполняется установка пакета: {package_input}") | |
install_package(package_input) | |
st.text(f"Установка пакета {package_input} завершена") | |
st.subheader("Консоль") | |
command_input = st.text_input("Введите команду") | |
if st.button("Выполнить"): | |
process = subprocess.Popen(command_input, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) | |
for line in process.stdout: | |
st.text(line.rstrip()) | |
process.wait() | |
if st.button("Очистить вывод"): | |
st.text("") | |
if __name__ == "__main__": | |
main() | |