Kiran5 commited on
Commit
08c8442
·
1 Parent(s): 68ecef9

adding files

Browse files
Files changed (1) hide show
  1. main.py +8 -6
main.py CHANGED
@@ -169,16 +169,17 @@ logging.info(f"THREADS: {os.getenv('THREADS', 'Not Set')}")
169
  logging.info(f"CONNECTION_LIMIT: {os.getenv('CONNECTION_LIMIT', 'Not Set')}")
170
  logging.info(f"CHANNEL_TIMEOUT: {os.getenv('CHANNEL_TIMEOUT', 'Not Set')}")
171
 
172
- # Use Flask development server for Hugging Face Spaces compatibility (instead of Waitress)
173
  if __name__ == "__main__":
174
  try:
175
- # Log the server startup info
176
  logging.info("Starting Flask application...")
177
-
178
- # Start the Flask application with the development server for testing
179
- app1.run(host="0.0.0.0", port=int(os.getenv("PORT", 7860)), threaded=True)
 
 
180
  except Exception as e:
181
- logging.error(f"Error starting Flask application: {e}")
182
  raise
183
 
184
 
@@ -189,3 +190,4 @@ if __name__ == "__main__":
189
 
190
 
191
 
 
 
169
  logging.info(f"CONNECTION_LIMIT: {os.getenv('CONNECTION_LIMIT', 'Not Set')}")
170
  logging.info(f"CHANNEL_TIMEOUT: {os.getenv('CHANNEL_TIMEOUT', 'Not Set')}")
171
 
172
+ # Use Waitress for production server, or Flask for development
173
  if __name__ == "__main__":
174
  try:
 
175
  logging.info("Starting Flask application...")
176
+ port = int(os.getenv("PORT", 7860)) # Default to 7860 if PORT is not set
177
+ logging.info(f"Flask app is starting on port {port}...")
178
+ serve(app1, host="0.0.0.0", port=port, threads=int(os.getenv('THREADS', 6)),
179
+ connection_limit=int(os.getenv('CONNECTION_LIMIT', 500)),
180
+ channel_timeout=int(os.getenv('CHANNEL_TIMEOUT', 120)))
181
  except Exception as e:
182
+ logging.error(f"Error starting Flask application with Waitress: {e}")
183
  raise
184
 
185
 
 
190
 
191
 
192
 
193
+