Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
|
5 |
+
def get_random_gifs(directory, num_gifs):
|
6 |
+
gif_files = [f for f in os.listdir(directory) if f.endswith('.gif')]
|
7 |
+
return random.sample(gif_files, num_gifs)
|
8 |
+
|
9 |
+
def main():
|
10 |
+
st.title('Random GIFs')
|
11 |
+
|
12 |
+
directory = './gifs' # Replace with your directory of GIFs
|
13 |
+
gif_files = get_random_gifs(directory, 9)
|
14 |
+
|
15 |
+
cols = st.beta_columns(3)
|
16 |
+
|
17 |
+
for i in range(3):
|
18 |
+
for j in range(3):
|
19 |
+
gif_file = gif_files[i*3 + j]
|
20 |
+
cols[j].image(os.path.join(directory, gif_file), width=200)
|
21 |
+
|
22 |
+
if st.button('Randomize'):
|
23 |
+
gif_files = get_random_gifs(directory, 9)
|
24 |
+
for i in range(3):
|
25 |
+
for j in range(3):
|
26 |
+
gif_file = gif_files[i*3 + j]
|
27 |
+
cols[j].image(os.path.join(directory, gif_file), width=200)
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
main()
|