File size: 1,159 Bytes
920c25b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
"""
WSGI entry point for production deployment
"""

import os
import sys
import logging
from pathlib import Path

# Add the current directory to Python path
current_dir = Path(__file__).parent
sys.path.insert(0, str(current_dir))

# Set up logging for production
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)

# Import the Flask app
try:
    from app import app
    
    # Configure for production
    app.config['DEBUG'] = False
    app.config['TESTING'] = False
    
    # Create upload directory
    upload_dir = app.config.get('UPLOAD_FOLDER', 'static/uploads')
    if upload_dir.startswith('/tmp'):
        # For platforms like Render that use /tmp
        os.makedirs(upload_dir, exist_ok=True)
    else:
        # For local deployment
        os.makedirs(upload_dir, exist_ok=True)
    
    logging.info("EpiPred application initialized successfully")
    
except Exception as e:
    logging.error(f"Failed to initialize application: {e}")
    raise

if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)