niru-nny commited on
Commit
5b162d1
·
1 Parent(s): 5430b1a

Fix gunicorn app loading issue

Browse files

- Add wsgi.py as dedicated WSGI entry point
- Update Dockerfile CMD to use wsgi:app instead of app:app
- Add PYTHONUNBUFFERED=1 for better logging
- Ensure production config is used in Hugging Face Spaces

Files changed (2) hide show
  1. Dockerfile +2 -2
  2. wsgi.py +16 -0
Dockerfile CHANGED
@@ -64,12 +64,12 @@ USER app
64
  EXPOSE 7860
65
 
66
  # Set environment variables
67
- ENV FLASK_APP=app.py
68
  ENV FLASK_ENV=production
 
69
 
70
  # Health check
71
  HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
72
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/api/health')" || exit 1
73
 
74
  # Production server command for Hugging Face Spaces
75
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "--access-logfile", "-", "--error-logfile", "-", "app:app"]
 
64
  EXPOSE 7860
65
 
66
  # Set environment variables
 
67
  ENV FLASK_ENV=production
68
+ ENV PYTHONUNBUFFERED=1
69
 
70
  # Health check
71
  HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
72
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/api/health')" || exit 1
73
 
74
  # Production server command for Hugging Face Spaces
75
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "--access-logfile", "-", "--error-logfile", "-", "wsgi:app"]
wsgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ WSGI Entry Point for PhotoGuard API
3
+ ====================================
4
+ Production entry point for running the application with WSGI servers like Gunicorn.
5
+ """
6
+
7
+ import os
8
+ from app import create_app
9
+
10
+ # Create Flask application instance
11
+ # Use production config for Hugging Face Spaces deployment
12
+ app = create_app(os.getenv('FLASK_ENV', 'production'))
13
+
14
+ if __name__ == '__main__':
15
+ # This is for debugging only
16
+ app.run(host='0.0.0.0', port=7860)