Update app.py
Browse files
app.py
CHANGED
@@ -46,8 +46,14 @@ def serve_static(path):
|
|
46 |
|
47 |
@app.route('/assets/<path:path>')
|
48 |
def serve_assets(path):
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
@app.route('/wishes/<path:path>')
|
52 |
def serve_wishes(path):
|
53 |
return send_from_directory('data/wishes', path)
|
@@ -950,10 +956,26 @@ def create_interface():
|
|
950 |
gr.Markdown("## 聽身, 請神 (몸의 소리를 듣고 신을 청하다) ")
|
951 |
gr.HTML("""
|
952 |
<div class="audio-player-container">
|
953 |
-
<audio controls
|
954 |
-
<source src="
|
955 |
</audio>
|
956 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
957 |
<style>
|
958 |
.audio-player-container {
|
959 |
width: 100%;
|
@@ -1344,7 +1366,13 @@ def create_interface():
|
|
1344 |
return app
|
1345 |
|
1346 |
if __name__ == "__main__":
|
1347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1348 |
sw_content = """
|
1349 |
const CACHE_NAME = 'digital-gutpan-v2';
|
1350 |
const urlsToCache = [
|
|
|
46 |
|
47 |
@app.route('/assets/<path:path>')
|
48 |
def serve_assets(path):
|
49 |
+
try:
|
50 |
+
if path.endswith('.mp3'):
|
51 |
+
return send_from_directory('assets', path, mimetype='audio/mpeg')
|
52 |
+
return send_from_directory('assets', path)
|
53 |
+
except Exception as e:
|
54 |
+
print(f"Asset serving error: {e}")
|
55 |
+
return f"Error serving asset: {path}", 404
|
56 |
+
|
57 |
@app.route('/wishes/<path:path>')
|
58 |
def serve_wishes(path):
|
59 |
return send_from_directory('data/wishes', path)
|
|
|
956 |
gr.Markdown("## 聽身, 請神 (몸의 소리를 듣고 신을 청하다) ")
|
957 |
gr.HTML("""
|
958 |
<div class="audio-player-container">
|
959 |
+
<audio id="bgMusic" controls preload="auto" style="width: 100%; max-width: 500px;">
|
960 |
+
<source src="assets/main_music.mp3" type="audio/mpeg">
|
961 |
</audio>
|
962 |
</div>
|
963 |
+
<script>
|
964 |
+
document.addEventListener('DOMContentLoaded', function() {
|
965 |
+
const audio = document.getElementById('bgMusic');
|
966 |
+
if(audio) {
|
967 |
+
console.log('Audio element found');
|
968 |
+
audio.onerror = function(e) {
|
969 |
+
console.error('Audio error:', e);
|
970 |
+
};
|
971 |
+
audio.onloadeddata = function() {
|
972 |
+
console.log('Audio loaded successfully');
|
973 |
+
};
|
974 |
+
} else {
|
975 |
+
console.error('Audio element not found');
|
976 |
+
}
|
977 |
+
});
|
978 |
+
</script>
|
979 |
<style>
|
980 |
.audio-player-container {
|
981 |
width: 100%;
|
|
|
1366 |
return app
|
1367 |
|
1368 |
if __name__ == "__main__":
|
1369 |
+
audio_path = os.path.join('assets', 'main_music.mp3')
|
1370 |
+
if os.path.exists(audio_path):
|
1371 |
+
print(f"✅ Audio file found: {audio_path}")
|
1372 |
+
print(f" Size: {os.path.getsize(audio_path)} bytes")
|
1373 |
+
print(f" Absolute path: {os.path.abspath(audio_path)}")
|
1374 |
+
else:
|
1375 |
+
print(f"❌ Audio file not found: {audio_path}")
|
1376 |
sw_content = """
|
1377 |
const CACHE_NAME = 'digital-gutpan-v2';
|
1378 |
const urlsToCache = [
|