Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2674,88 +2674,188 @@ async def index():
|
|
2674 |
"""Serve the HTML page"""
|
2675 |
rtc_config = get_twilio_turn_credentials() if get_space() else None
|
2676 |
|
2677 |
-
#
|
2678 |
test_html = """<!DOCTYPE html>
|
2679 |
<html lang="ko">
|
2680 |
<head>
|
2681 |
<meta charset="UTF-8">
|
2682 |
<title>MOUSE Extended</title>
|
2683 |
<style>
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2689 |
</style>
|
2690 |
</head>
|
2691 |
<body>
|
2692 |
-
<h1>MOUSE Extended -
|
2693 |
|
2694 |
-
<div>
|
2695 |
-
<button class="tab-button active" onclick="switchTab('
|
2696 |
-
<button class="tab-button" onclick="switchTab('
|
2697 |
-
<button class="tab-button" onclick="switchTab('
|
2698 |
</div>
|
2699 |
|
2700 |
-
<div id="
|
2701 |
<h2>Voice Chat Tab</h2>
|
2702 |
-
<
|
2703 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2704 |
</div>
|
2705 |
|
2706 |
-
<div id="
|
2707 |
-
<h2
|
|
|
2708 |
</div>
|
2709 |
|
2710 |
-
<div id="
|
2711 |
-
<h2
|
|
|
|
|
|
|
2712 |
</div>
|
2713 |
-
|
2714 |
<script>
|
2715 |
-
console.log('Script
|
|
|
|
|
|
|
|
|
2716 |
|
|
|
2717 |
function switchTab(tabName) {
|
2718 |
console.log('Switching to:', tabName);
|
2719 |
|
2720 |
-
// Hide all tabs
|
2721 |
document.querySelectorAll('.tab-content').forEach(tab => {
|
2722 |
tab.style.display = 'none';
|
2723 |
tab.classList.remove('active');
|
2724 |
});
|
2725 |
|
2726 |
-
|
|
|
|
|
|
|
2727 |
const selectedTab = document.getElementById(tabName);
|
2728 |
if (selectedTab) {
|
2729 |
selectedTab.style.display = 'block';
|
2730 |
selectedTab.classList.add('active');
|
2731 |
}
|
2732 |
|
2733 |
-
// Update buttons
|
2734 |
-
document.querySelectorAll('.tab-button').forEach(btn => {
|
2735 |
-
btn.classList.remove('active');
|
2736 |
-
});
|
2737 |
event.target.classList.add('active');
|
2738 |
}
|
2739 |
|
2740 |
-
|
2741 |
-
|
|
|
|
|
|
|
|
|
|
|
2742 |
}
|
2743 |
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2747 |
|
2748 |
-
// Search toggle
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2757 |
|
2758 |
-
console.log('Script
|
2759 |
</script>
|
2760 |
</body>
|
2761 |
</html>"""
|
|
|
2674 |
"""Serve the HTML page"""
|
2675 |
rtc_config = get_twilio_turn_credentials() if get_space() else None
|
2676 |
|
2677 |
+
# Step 1: μλ HTMLμ κΈ°λ³Έ κ΅¬μ‘°λ‘ μμ
|
2678 |
test_html = """<!DOCTYPE html>
|
2679 |
<html lang="ko">
|
2680 |
<head>
|
2681 |
<meta charset="UTF-8">
|
2682 |
<title>MOUSE Extended</title>
|
2683 |
<style>
|
2684 |
+
:root {
|
2685 |
+
--primary-color: #6f42c1;
|
2686 |
+
--secondary-color: #563d7c;
|
2687 |
+
--dark-bg: #121212;
|
2688 |
+
--card-bg: #1e1e1e;
|
2689 |
+
--text-color: #f8f9fa;
|
2690 |
+
--border-color: #333;
|
2691 |
+
}
|
2692 |
+
body {
|
2693 |
+
background-color: var(--dark-bg);
|
2694 |
+
color: var(--text-color);
|
2695 |
+
font-family: Arial, sans-serif;
|
2696 |
+
margin: 0;
|
2697 |
+
padding: 20px;
|
2698 |
+
}
|
2699 |
+
.tab-button {
|
2700 |
+
padding: 10px 20px;
|
2701 |
+
margin: 5px;
|
2702 |
+
cursor: pointer;
|
2703 |
+
background: var(--card-bg);
|
2704 |
+
border: 1px solid var(--border-color);
|
2705 |
+
color: var(--text-color);
|
2706 |
+
}
|
2707 |
+
.tab-button.active {
|
2708 |
+
background: var(--primary-color);
|
2709 |
+
}
|
2710 |
+
.tab-content {
|
2711 |
+
display: none;
|
2712 |
+
padding: 20px;
|
2713 |
+
background: var(--card-bg);
|
2714 |
+
margin-top: 20px;
|
2715 |
+
}
|
2716 |
+
.tab-content.active {
|
2717 |
+
display: block;
|
2718 |
+
}
|
2719 |
+
.toggle-switch {
|
2720 |
+
width: 50px;
|
2721 |
+
height: 26px;
|
2722 |
+
background: #ccc;
|
2723 |
+
cursor: pointer;
|
2724 |
+
display: inline-block;
|
2725 |
+
}
|
2726 |
+
.toggle-switch.active {
|
2727 |
+
background: var(--primary-color);
|
2728 |
+
}
|
2729 |
</style>
|
2730 |
</head>
|
2731 |
<body>
|
2732 |
+
<h1>MOUSE Extended - Step 1</h1>
|
2733 |
|
2734 |
+
<div class="tabs-container">
|
2735 |
+
<button class="tab-button active" onclick="switchTab('voice-chat')">μμ± μ±ν
</button>
|
2736 |
+
<button class="tab-button" onclick="switchTab('mic-whisper')">λ§μ΄ν¬ μ μ¬</button>
|
2737 |
+
<button class="tab-button" onclick="switchTab('audio-whisper')">μ€λμ€ νμΌ</button>
|
2738 |
</div>
|
2739 |
|
2740 |
+
<div id="voice-chat" class="tab-content active">
|
2741 |
<h2>Voice Chat Tab</h2>
|
2742 |
+
<div>
|
2743 |
+
<label>μΉ κ²μ:</label>
|
2744 |
+
<div id="search-toggle" class="toggle-switch"></div>
|
2745 |
+
</div>
|
2746 |
+
<div>
|
2747 |
+
<label>μΈμ΄ μ ν:</label>
|
2748 |
+
<select id="language-select">
|
2749 |
+
<option value="">λΉνμ±ν</option>
|
2750 |
+
<option value="ko">νκ΅μ΄</option>
|
2751 |
+
<option value="en">English</option>
|
2752 |
+
</select>
|
2753 |
+
</div>
|
2754 |
+
<button id="start-button">λν μμ</button>
|
2755 |
+
<input type="text" id="text-input" placeholder="λ©μμ§ μ
λ ₯...">
|
2756 |
+
<button id="send-button">μ μ‘</button>
|
2757 |
</div>
|
2758 |
|
2759 |
+
<div id="mic-whisper" class="tab-content">
|
2760 |
+
<h2>λ§μ΄ν¬ μ μ¬</h2>
|
2761 |
+
<button onclick="toggleMicRecording()">λ
Ήμ μμ</button>
|
2762 |
</div>
|
2763 |
|
2764 |
+
<div id="audio-whisper" class="tab-content">
|
2765 |
+
<h2>μ€λμ€ νμΌ</h2>
|
2766 |
+
<div id="audio-upload-area" style="border: 2px dashed #666; padding: 20px; cursor: pointer;">
|
2767 |
+
ν΄λ¦νμ¬ μ
λ‘λ
|
2768 |
+
</div>
|
2769 |
</div>
|
2770 |
+
|
2771 |
<script>
|
2772 |
+
console.log('=== Script Start ===');
|
2773 |
+
|
2774 |
+
// Global variables
|
2775 |
+
let webSearchEnabled = false;
|
2776 |
+
let selectedLanguage = "";
|
2777 |
|
2778 |
+
// Tab switching
|
2779 |
function switchTab(tabName) {
|
2780 |
console.log('Switching to:', tabName);
|
2781 |
|
|
|
2782 |
document.querySelectorAll('.tab-content').forEach(tab => {
|
2783 |
tab.style.display = 'none';
|
2784 |
tab.classList.remove('active');
|
2785 |
});
|
2786 |
|
2787 |
+
document.querySelectorAll('.tab-button').forEach(btn => {
|
2788 |
+
btn.classList.remove('active');
|
2789 |
+
});
|
2790 |
+
|
2791 |
const selectedTab = document.getElementById(tabName);
|
2792 |
if (selectedTab) {
|
2793 |
selectedTab.style.display = 'block';
|
2794 |
selectedTab.classList.add('active');
|
2795 |
}
|
2796 |
|
|
|
|
|
|
|
|
|
2797 |
event.target.classList.add('active');
|
2798 |
}
|
2799 |
|
2800 |
+
// Mock functions
|
2801 |
+
function toggleMicRecording() {
|
2802 |
+
alert('Mic recording toggle');
|
2803 |
+
}
|
2804 |
+
|
2805 |
+
function setupWebRTC() {
|
2806 |
+
alert('WebRTC setup');
|
2807 |
}
|
2808 |
|
2809 |
+
function stop() {
|
2810 |
+
alert('Stop');
|
2811 |
+
}
|
2812 |
+
|
2813 |
+
function sendTextMessage() {
|
2814 |
+
const input = document.getElementById('text-input');
|
2815 |
+
alert('Send: ' + input.value);
|
2816 |
+
}
|
2817 |
+
|
2818 |
+
// Initialize
|
2819 |
+
window.onload = function() {
|
2820 |
+
console.log('=== Window loaded ===');
|
2821 |
|
2822 |
+
// Search toggle
|
2823 |
+
document.getElementById('search-toggle').onclick = function() {
|
2824 |
+
webSearchEnabled = !webSearchEnabled;
|
2825 |
+
this.classList.toggle('active');
|
2826 |
+
console.log('Search enabled:', webSearchEnabled);
|
2827 |
+
};
|
2828 |
+
|
2829 |
+
// Language select
|
2830 |
+
document.getElementById('language-select').onchange = function() {
|
2831 |
+
selectedLanguage = this.value;
|
2832 |
+
console.log('Language:', selectedLanguage);
|
2833 |
+
};
|
2834 |
+
|
2835 |
+
// Start button
|
2836 |
+
document.getElementById('start-button').onclick = function() {
|
2837 |
+
setupWebRTC();
|
2838 |
+
};
|
2839 |
+
|
2840 |
+
// Send button
|
2841 |
+
document.getElementById('send-button').onclick = sendTextMessage;
|
2842 |
+
|
2843 |
+
// Text input
|
2844 |
+
document.getElementById('text-input').onkeypress = function(e) {
|
2845 |
+
if (e.key === 'Enter') {
|
2846 |
+
sendTextMessage();
|
2847 |
+
}
|
2848 |
+
};
|
2849 |
+
|
2850 |
+
// File upload
|
2851 |
+
document.getElementById('audio-upload-area').onclick = function() {
|
2852 |
+
alert('Audio upload clicked');
|
2853 |
+
};
|
2854 |
+
|
2855 |
+
console.log('=== All initialized ===');
|
2856 |
+
};
|
2857 |
|
2858 |
+
console.log('=== Script End ===');
|
2859 |
</script>
|
2860 |
</body>
|
2861 |
</html>"""
|