Shirochi commited on
Commit
8b89cda
·
verified ·
1 Parent(s): c10e971

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Glossarion Hugging Face Spaces Entry Point
4
+ Launches the full Glossarion Web Interface
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ from pathlib import Path
10
+
11
+ # Add current directory to Python path
12
+ current_dir = Path(__file__).parent
13
+ sys.path.insert(0, str(current_dir))
14
+
15
+ def main():
16
+ """Main entry point for Hugging Face Spaces"""
17
+
18
+ # Set environment variables for Hugging Face Spaces
19
+ os.environ['HF_SPACES'] = 'true'
20
+ os.environ['GRADIO_SHARE'] = 'false'
21
+
22
+ try:
23
+ # Import and launch the existing Glossarion Web interface
24
+ from glossarion_web import GlossarionWeb
25
+
26
+ print("🚀 Starting Glossarion Web Interface on Hugging Face Spaces...")
27
+
28
+ web_app = GlossarionWeb()
29
+ app = web_app.create_interface()
30
+
31
+ # Launch with Spaces-appropriate settings
32
+ app.launch(
33
+ server_name="0.0.0.0",
34
+ server_port=7860,
35
+ share=False,
36
+ show_error=True,
37
+ favicon_path=None # Skip favicon for Spaces
38
+ )
39
+
40
+ except Exception as e:
41
+ print(f"❌ Error launching Glossarion Web: {e}")
42
+ import traceback
43
+ traceback.print_exc()
44
+
45
+ # Fallback: show error message
46
+ import gradio as gr
47
+
48
+ def error_interface():
49
+ with gr.Blocks(title="Glossarion - Error") as error_app:
50
+ gr.HTML(f"""
51
+ <div style="text-align: center; padding: 50px;">
52
+ <h1>❌ Glossarion Failed to Load</h1>
53
+ <p><strong>Error:</strong> {str(e)}</p>
54
+ <p>Please check the logs for more details.</p>
55
+ <p>You may need to install missing dependencies or check module imports.</p>
56
+ </div>
57
+ """)
58
+ return error_app
59
+
60
+ error_app = error_interface()
61
+ error_app.launch(
62
+ server_name="0.0.0.0",
63
+ server_port=7860,
64
+ share=False
65
+ )
66
+
67
+ if __name__ == "__main__":
68
+ main()