Turbiling commited on
Commit
a0ab2cc
·
verified ·
1 Parent(s): b2e771f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -8
app.py CHANGED
@@ -905,12 +905,42 @@ def create_ui():
905
  # ---------------------------
906
  # Launch application
907
  # ---------------------------
908
- if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
909
  demo = create_ui()
910
- demo.launch(
911
- share=False, # Set to True for Hugging Face Spaces
912
- server_name="0.0.0.0",
913
- server_port=7860,
914
- show_error=True,
915
- favicon_path=None
916
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
905
  # ---------------------------
906
  # Launch application
907
  # ---------------------------
908
+ try:
909
+ print("🚀 Starting MCQ Test Generator Pro v2.0")
910
+ print(f"📦 Gradio version: {gr.__version__}")
911
+
912
+ # Check API key
913
+ if not GROQ_API_KEY:
914
+ print("⚠️ WARNING: GROQ_API_KEY not found in environment variables")
915
+ print("Please set it in Hugging Face Space Settings > Repository secrets")
916
+ else:
917
+ print(f"✅ API Key configured (length: {len(GROQ_API_KEY)})")
918
+
919
+ # Create and launch
920
  demo = create_ui()
921
+ print("✅ UI created successfully")
922
+
923
+ demo.queue() # Enable queue for better handling
924
+ demo.launch()
925
+
926
+ except Exception as e:
927
+ print(f"❌ Critical Error: {str(e)}")
928
+ import traceback
929
+ traceback.print_exc()
930
+
931
+ # Create minimal error interface
932
+ with gr.Blocks() as error_demo:
933
+ gr.Markdown(f"""
934
+ # ❌ Application Error
935
+
936
+ **Error Message:** {str(e)}
937
+
938
+ **Common Solutions:**
939
+ 1. Check if GROQ_API_KEY is set in Space settings
940
+ 2. Verify all dependencies are installed
941
+ 3. Check the build logs for errors
942
+
943
+ **Contact:** Developer - Najaf Ali Sharqi
944
+ """)
945
+
946
+ error_demo.launch()