singarajusaiteja's picture
update app.py
5a1a2bc verified
#!/usr/bin/env python3
"""
Hugging Face Spaces Entry Point for Corpus Collection Engine
AI-powered platform for preserving Indian cultural heritage
"""
import gradio as gr
import subprocess
import threading
import time
import sys
import os
def launch_streamlit():
"""Launch Streamlit app in background"""
try:
# Launch the Streamlit app from the corpus_collection_engine directory
subprocess.Popen([
sys.executable, "-m", "streamlit", "run",
"corpus_collection_engine/main.py",
"--server.port=7861",
"--server.address=0.0.0.0",
"--server.headless=true"
])
except Exception as e:
print(f"Error launching Streamlit: {e}")
def create_interface():
"""Create Gradio interface that embeds the Streamlit app"""
# Launch Streamlit in background
streamlit_thread = threading.Thread(target=launch_streamlit, daemon=True)
streamlit_thread.start()
# Wait for Streamlit to start
time.sleep(10)
# Create Gradio interface
with gr.Blocks(
title="๐Ÿ‡ฎ๐Ÿ‡ณ Corpus Collection Engine",
theme=gr.themes.Soft(),
css="""
.gradio-container {
max-width: 100% !important;
padding: 0 !important;
}
iframe {
border-radius: 10px !important;
}
"""
) as demo:
# Header
gr.HTML("""
<div style="text-align: center; padding: 25px; background: linear-gradient(135deg, #FF6B35, #F7931E); color: white; margin-bottom: 25px; border-radius: 15px; box-shadow: 0 4px 15px rgba(255,107,53,0.3);">
<h1 style="margin: 0; font-size: 2.8em; font-weight: bold;">๐Ÿ‡ฎ๐Ÿ‡ณ Corpus Collection Engine</h1>
<p style="margin: 15px 0 0 0; font-size: 1.3em; opacity: 0.95;">AI-powered platform for preserving Indian cultural heritage</p>
<p style="margin: 10px 0 0 0; font-size: 1em; opacity: 0.8;">No login required โ€ข Start contributing immediately</p>
</div>
""")
# Main app iframe
gr.HTML("""
<div style="background: white; border-radius: 15px; overflow: hidden; box-shadow: 0 8px 25px rgba(0,0,0,0.1); margin-bottom: 25px;">
<iframe
src="http://localhost:7861"
width="100%"
height="850px"
frameborder="0"
style="border-radius: 15px;"
allow="camera; microphone; clipboard-write"
></iframe>
</div>
""")
# Features showcase
gr.HTML("""
<div style="background: linear-gradient(135deg, #f8f9fa, #e9ecef); padding: 25px; border-radius: 15px; margin-top: 20px;">
<h3 style="text-align: center; margin: 0 0 20px 0; color: #333; font-size: 1.5em;">๐ŸŽฏ Cultural Activities Available</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px;">
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
<div style="font-size: 3em; margin-bottom: 10px;">๐ŸŽญ</div>
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Meme Creator</h4>
<p style="margin: 0; color: #666; font-size: 0.9em;">Create culturally relevant memes in Indian languages</p>
</div>
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
<div style="font-size: 3em; margin-bottom: 10px;">๐Ÿ›</div>
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Recipe Collector</h4>
<p style="margin: 0; color: #666; font-size: 0.9em;">Share traditional family recipes with cultural context</p>
</div>
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
<div style="font-size: 3em; margin-bottom: 10px;">๐Ÿ“š</div>
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Folklore Archive</h4>
<p style="margin: 0; color: #666; font-size: 0.9em;">Preserve stories, legends, and oral traditions</p>
</div>
<div style="text-align: center; padding: 20px; background: white; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);">
<div style="font-size: 3em; margin-bottom: 10px;">๐Ÿ›๏ธ</div>
<h4 style="margin: 0 0 8px 0; color: #FF6B35;">Landmark Identifier</h4>
<p style="margin: 0; color: #666; font-size: 0.9em;">Document historical and cultural landmarks</p>
</div>
</div>
<div style="text-align: center; margin-top: 25px; padding: 20px; background: rgba(255,107,53,0.1); border-radius: 10px;">
<h4 style="margin: 0 0 10px 0; color: #FF6B35;">๐ŸŒŸ Platform Features</h4>
<p style="margin: 0; color: #555; line-height: 1.6;">
<strong>๐ŸŒ 11 Indian Languages</strong> โ€ข
<strong>๐Ÿ“ฑ Mobile Responsive</strong> โ€ข
<strong>๐Ÿ”’ Privacy-First Design</strong> โ€ข
<strong>๐Ÿ“Š Real-time Analytics</strong> โ€ข
<strong>๐Ÿ† Achievement System</strong> โ€ข
<strong>โšก Offline Support</strong>
</p>
</div>
</div>
""")
# Footer
gr.HTML("""
<div style="text-align: center; padding: 20px; margin-top: 20px; color: #666; border-top: 1px solid #eee;">
<p style="margin: 0; font-size: 0.9em;">
Built with โค๏ธ for preserving Indian cultural heritage โ€ข
<strong>Start contributing today!</strong>
</p>
</div>
""")
return demo
if __name__ == "__main__":
# Create and launch the Gradio interface
demo = create_interface()
demo.launch(
server_port=7860,
server_name="0.0.0.0",
share=False,
show_error=True,
show_api=False
)