-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·32 lines (26 loc) · 968 Bytes
/
app.py
File metadata and controls
executable file
·32 lines (26 loc) · 968 Bytes
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
#!/usr/bin/env python
"""
Django WSGI entry point for high-performance load testing.
Use gunicorn for production-grade concurrency and performance.
"""
import os
import sys
from pathlib import Path
# Add the Django project directory to the Python path
BASE_DIR = Path(__file__).resolve().parent
sys.path.insert(0, str(BASE_DIR / 'sampleproject'))
# Set Django settings module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sampleproject.settings')
# Import Django utilities
import django
from django.core.wsgi import get_wsgi_application
def main():
django.setup()
application = get_wsgi_application()
return application
# For gunicorn, expose 'application' as module-level variable
application = main()
if __name__ == '__main__':
print("This script is intended to be run with gunicorn:")
print(" gunicorn app:application --workers 4 --threads 8 --bind 0.0.0.0:8000")
print("Or use your preferred gunicorn settings for load testing.")