MahmoudNabilMohamed commited on
Commit
d2ccaa1
·
verified ·
1 Parent(s): fa4d62f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -204,14 +204,18 @@ if __name__ == '__main__':
204
  exit(1)
205
 
206
  # إعداد المنفذ
207
- port = int(os.environ.get('PORT', 5000))
 
 
 
 
208
 
209
- print(f"📡 Running on port: {port}")
210
- print(f"🌐 Local URL: http://localhost:{port}")
211
- print(f"🔍 Health check: http://localhost:{port}/")
212
- print(f"📱 API endpoint: http://localhost:{port}/remove-background")
213
- print("💡 In Codespaces: Go to PORTS tab and make port 5000 public")
214
- print("=" * 60)
 
215
 
216
- # تشغيل السيرفر
217
- app.run(host='0.0.0.0', port=port, debug=False, threaded=True)
 
204
  exit(1)
205
 
206
  # إعداد المنفذ
207
+ if __name__ == '__main__':
208
+ if not background_remover.download_model():
209
+ exit(1)
210
+ if not background_remover.load_model():
211
+ exit(1)
212
 
213
+ # Hugging Face Spaces يستخدم المنفذ 7860
214
+ port = int(os.environ.get('PORT', 7860))
215
+ print(f'📡 Running on port: {port}')
216
+ print(f'🌐 Local URL: http://localhost:{port}')
217
+ print(f'🔍 Health check: http://localhost:{port}/')
218
+ print(f'📱 API endpoint: http://localhost:{port}/remove-background')
219
+ print('=' * 60)
220
 
221
+ app.run(host='0.0.0.0', port=port, debug=False)