用streamlit写一个购物网站的主页
时间: 2023-12-09 08:00:01 浏览: 35
好的,以下是一个简单的购物网站主页的 Streamlit 应用程序示例:
```python
import streamlit as st
def main():
st.set_page_config(page_title="My Shopping Website", page_icon=":money_with_wings:")
st.title("Welcome to My Shopping Website")
st.write("Here are some of our featured products:")
col1, col2, col3 = st.columns(3)
with col1:
st.image("https://picsum.photos/200/300?random=1", use_column_width=True)
st.write("Product 1")
st.write("$10")
with col2:
st.image("https://picsum.photos/200/300?random=2", use_column_width=True)
st.write("Product 2")
st.write("$20")
with col3:
st.image("https://picsum.photos/200/300?random=3", use_column_width=True)
st.write("Product 3")
st.write("$30")
st.write("To view more products, please login or sign up.")
if __name__ == "__main__":
main()
```
这个简单的应用程序创建了一个购物网站的主页,其中包含三个列,每一列都包含一个产品图像、产品名称和价格。用户可以通过登录或注册来查看更多产品。注意,示例中使用了 `picsum.photos` 服务来生成随机图像。在实际应用中,您可能需要使用自己的图像或其他图像服务。