daqc commited on
Commit
344f203
·
verified ·
1 Parent(s): 0402c9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -13
app.py CHANGED
@@ -1148,16 +1148,34 @@ This AI agent specializes in automated vulnerability research and analysis, buil
1148
  )
1149
 
1150
 
1151
- demo.launch(
1152
- debug=True,
1153
- server_name="localhost",
1154
- server_port=7860,
1155
- share=False,
1156
- **kwargs
1157
- )
1158
-
1159
- # can this fix ctrl-c no response? no
1160
- try:
1161
- GradioUI(file_upload_folder="uploads").launch()
1162
- except KeyboardInterrupt:
1163
- ...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1148
  )
1149
 
1150
 
1151
+ # Configure for Hugging Face Spaces compatibility
1152
+ is_spaces = os.getenv("SPACE_ID") is not None
1153
+
1154
+ if is_spaces:
1155
+ # Hugging Face Spaces configuration
1156
+ demo.launch(
1157
+ debug=False,
1158
+ server_name="0.0.0.0",
1159
+ server_port=int(os.getenv("PORT", 7860)),
1160
+ share=True,
1161
+ **kwargs
1162
+ )
1163
+ else:
1164
+ # Local development configuration
1165
+ demo.launch(
1166
+ debug=True,
1167
+ server_name="localhost",
1168
+ server_port=7860,
1169
+ share=False,
1170
+ **kwargs
1171
+ )
1172
+
1173
+ # Launch the application
1174
+ if __name__ == "__main__":
1175
+ try:
1176
+ GradioUI(file_upload_folder="uploads").launch()
1177
+ except KeyboardInterrupt:
1178
+ print("Application stopped by user")
1179
+ except Exception as e:
1180
+ print(f"Error starting application: {e}")
1181
+ raise