Spaces:
Runtime error
Runtime error
init
Browse files- app.py +41 -0
- data/data.csv +0 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
if 'selected_series' not in st.session_state:
|
| 6 |
+
st.session_state.selected_series = None
|
| 7 |
+
|
| 8 |
+
if 'button_clicked' not in st.session_state:
|
| 9 |
+
st.session_state.button_clicked = False
|
| 10 |
+
|
| 11 |
+
st.title('Генератор случайных сериалов')
|
| 12 |
+
st.divider()
|
| 13 |
+
|
| 14 |
+
data = pd.read_csv('data/data.csv', index_col=0)
|
| 15 |
+
|
| 16 |
+
if st.button('Дай 10 сериалов', use_container_width=True):
|
| 17 |
+
st.session_state.button_clicked = True
|
| 18 |
+
st.session_state.selected_series = None
|
| 19 |
+
|
| 20 |
+
if st.session_state.button_clicked:
|
| 21 |
+
for _ in range(10):
|
| 22 |
+
number = random.randint(0, data.shape[0] - 1)
|
| 23 |
+
with st.form(key=f'Сериал_{number}'):
|
| 24 |
+
col1, col2, col3 = st.columns(3)
|
| 25 |
+
|
| 26 |
+
with col1:
|
| 27 |
+
st.image(data.iloc[number, 1])
|
| 28 |
+
with col2:
|
| 29 |
+
st.subheader(data.iloc[number, 2])
|
| 30 |
+
st.caption(data.iloc[number, 3])
|
| 31 |
+
with col3:
|
| 32 |
+
with st.popover('Описание'):
|
| 33 |
+
st.write(data.iloc[number, 4])
|
| 34 |
+
st.caption('Ссылка')
|
| 35 |
+
st.caption(data.iloc[number, 0])
|
| 36 |
+
if st.form_submit_button('Обновить'):
|
| 37 |
+
pass
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
data/data.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
streamlit
|