awacke1 commited on
Commit
96c1962
·
verified ·
1 Parent(s): 035d4dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -2
app.py CHANGED
@@ -772,8 +772,26 @@ def update_file_management_section():
772
  display_file_editor(st.session_state.current_file)
773
 
774
 
 
 
 
 
 
 
 
 
 
775
 
776
-
 
 
 
 
 
 
 
 
 
777
  # 🎭 Main function - "All the world's a stage, and all the code merely players" -Shakespeare, probably
778
  def main():
779
  st.markdown("### 🐙Git🌌Cosmos💫 - Azure Cosmos DB and Github Agent")
@@ -1146,7 +1164,48 @@ def main():
1146
  except Exception as e:
1147
  st.error(f"Error saving document: {str(e)}")
1148
 
1149
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1150
 
1151
 
1152
 
 
772
  display_file_editor(st.session_state.current_file)
773
 
774
 
775
+ # Function to create HTML for autoplaying and looping video (for the full cinematic effect 🎥)
776
+ def get_video_html(video_path, width="100%"):
777
+ video_url = f"data:video/mp4;base64,{base64.b64encode(open(video_path, 'rb').read()).decode()}"
778
+ return f'''
779
+ <video width="{width}" controls autoplay muted loop>
780
+ <source src="{video_url}" type="video/mp4">
781
+ Your browser does not support the video tag.
782
+ </video>
783
+ '''
784
 
785
+ # Function to create HTML for audio player (when life needs a soundtrack 🎶)
786
+ def get_audio_html(audio_path, width="100%"):
787
+ audio_url = f"data:audio/mpeg;base64,{base64.b64encode(open(audio_path, 'rb').read()).decode()}"
788
+ return f'''
789
+ <audio controls style="width: {width};">
790
+ <source src="{audio_url}" type="audio/mpeg">
791
+ Your browser does not support the audio element.
792
+ </audio>
793
+ '''
794
+
795
  # 🎭 Main function - "All the world's a stage, and all the code merely players" -Shakespeare, probably
796
  def main():
797
  st.markdown("### 🐙Git🌌Cosmos💫 - Azure Cosmos DB and Github Agent")
 
1164
  except Exception as e:
1165
  st.error(f"Error saving document: {str(e)}")
1166
 
1167
+
1168
+ # File Editor (When you need to tweak things ✏️)
1169
+ if hasattr(st.session_state, 'current_file'):
1170
+ st.subheader(f"Editing: {st.session_state.current_file} 🛠")
1171
+ new_content = st.text_area("File Content ✏️:", st.session_state.file_content, height=300)
1172
+ if st.button("Save Changes 💾"):
1173
+ with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
1174
+ file.write(new_content)
1175
+ st.success("File updated successfully! 🎉")
1176
+
1177
+ # Image Gallery (For your viewing pleasure 📸)
1178
+ st.subheader("Image Gallery 🖼")
1179
+ image_files = glob.glob("*.png") + glob.glob("*.jpg") + glob.glob("*.jpeg")
1180
+ image_cols = st.slider("Gallery Columns 🖼", min_value=1, max_value=15, value=5)
1181
+ cols = st.columns(image_cols)
1182
+ for idx, image_file in enumerate(image_files):
1183
+ with cols[idx % image_cols]:
1184
+ img = Image.open(image_file)
1185
+ #st.image(img, caption=image_file, use_column_width=True)
1186
+ st.image(img, use_column_width=True)
1187
+ display_glossary_entity(os.path.splitext(image_file)[0])
1188
+
1189
+ # Video Gallery (Let’s roll the tapes 🎬)
1190
+ st.subheader("Video Gallery 🎥")
1191
+ video_files = glob.glob("*.mp4")
1192
+ video_cols = st.slider("Gallery Columns 🎬", min_value=1, max_value=5, value=3)
1193
+ cols = st.columns(video_cols)
1194
+ for idx, video_file in enumerate(video_files):
1195
+ with cols[idx % video_cols]:
1196
+ st.markdown(get_video_html(video_file, width="100%"), unsafe_allow_html=True)
1197
+ display_glossary_entity(os.path.splitext(video_file)[0])
1198
+
1199
+ # Audio Gallery (Tunes for the mood 🎶)
1200
+ st.subheader("Audio Gallery 🎧")
1201
+ audio_files = glob.glob("*.mp3") + glob.glob("*.wav")
1202
+ audio_cols = st.slider("Gallery Columns 🎶", min_value=1, max_value=15, value=5)
1203
+ cols = st.columns(audio_cols)
1204
+ for idx, audio_file in enumerate(audio_files):
1205
+ with cols[idx % audio_cols]:
1206
+ st.markdown(get_audio_html(audio_file, width="100%"), unsafe_allow_html=True)
1207
+ display_glossary_entity(os.path.splitext(audio_file)[0])
1208
+
1209
 
1210
 
1211