Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,24 @@
|
|
| 1 |
-
|
| 2 |
-
FROM python:3.9-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
-
EXPOSE 7860
|
| 20 |
|
| 21 |
-
# Run the Gunicorn server when the container launches
|
| 22 |
-
# It will serve your Flask 'app' object from the 'app.py' file
|
| 23 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|
| 24 |
-
```
|
|
|
|
| 1 |
+
from flask import Flask, send_from_directory
|
|
|
|
| 2 |
|
| 3 |
+
# Initialize the Flask application
|
| 4 |
+
# The static_folder is set to the current directory to serve all frontend files.
|
| 5 |
+
app = Flask(__name__, static_folder='.', static_url_path='')
|
| 6 |
|
| 7 |
+
@app.route('/')
|
| 8 |
+
def index():
|
| 9 |
+
"""Serves the main HTML file for the web application."""
|
| 10 |
+
return send_from_directory('.', 'index.html')
|
| 11 |
|
| 12 |
+
@app.route('/sw.js')
|
| 13 |
+
def serve_sw():
|
| 14 |
+
"""Serves the Service Worker file."""
|
| 15 |
+
return send_from_directory('.', 'sw.js')
|
| 16 |
|
| 17 |
+
@app.route('/manifest.json')
|
| 18 |
+
def serve_manifest():
|
| 19 |
+
"""Serves the PWA manifest file."""
|
| 20 |
+
return send_from_directory('.', 'manifest.json')
|
| 21 |
|
| 22 |
+
# The 'if __name__ == "__main__"' block is removed.
|
| 23 |
+
# Gunicorn will directly interface with the 'app' object.
|
|
|
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|