-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi.py
38 lines (33 loc) · 1018 Bytes
/
wsgi.py
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
import os
import sys
from pathlib import Path
import logging
# Configure logging for production
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [%(levelname)s] [%(name)s] %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.handlers.RotatingFileHandler(
'app.log',
maxBytes=1024 * 1024, # 1MB
backupCount=3
)
]
)
# Set external library logging levels
logging.getLogger('werkzeug').setLevel(logging.WARNING)
logging.getLogger('gunicorn').setLevel(logging.INFO)
# Add the project root directory to Python path
project_root = Path(__file__).parent.absolute()
sys.path.append(str(project_root))
try:
from src.main import create_app
app = create_app()
logging.info("Application created successfully")
except Exception as e:
logging.error(f"Failed to create application: {e}")
raise
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host="0.0.0.0", port=port)