import streamlit as st
def main():
st.title("액자 사진 갤러리")
uploaded_files = st.file_uploader("여러 사진 파일을 업로드하세요.", accept_multiple_files=True)
if uploaded_files:
image_files = list(uploaded_files)
image_files.sort(key=lambda x: x.name)
st.write(f"총 {len(image_files) }개의 사진이 업로드 되었습니다.")
for image_file in image_files:
st.image(image_file, use_column_width=True, caption=image_file.name)
if __name__ == '__main__':
main()
import streamlit as st
number = st.slider("숫자 선택", 0, 10)
st.write(f"선택한 숫자 {number}입니다.")
import streamlit as st
def main():
st.title("액자 사진 갤러리")
uploaded_files = st.file_uploader("여러 사진 파일을 업로드하세요.", accept_multiple_files=True)
if uploaded_files:
image_files = list(uploaded_files)
image_files.sort(key=lambda x: x.name)
st.write(f"총 {len(image_files)}개의 사진이 업로드 되었습니다.")
index = st.slider("이미지 선택", 0, len(image_files)-1, 0)
st.image(image_files[index], use_column_width=True, caption=image_files[index].name)
if __name__ == '__main__':
main()
사전 준비
시작하기 전에 다음을 준비해야 합니다:
Streamlit 설치:
pip install streamlit
이미지 파일 준비:
코드 실행:
코드를 .py 파일(예: photo_gallery.py)로 저장합니다.
터미널에서 다음 명령어로 실행합니다:
streamlit run photo_gallery.py
실행 후, 브라우저에서 http://localhost:8501로 접속해 결과를 확인합니다.
코드 주요 부분 설명
import streamlit as st