sanch1tx commited on
Commit
1a78c60
·
verified ·
1 Parent(s): 4dc7a8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -1,24 +1,24 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
 
6
 
7
- # Copy the requirements file into the container at /app
8
- # This is done first to leverage Docker's layer caching
9
- COPY requirements.txt .
 
10
 
11
- # Install any needed packages specified in requirements.txt
12
- RUN pip install --no-cache-dir -r requirements.txt
 
 
13
 
14
- # Copy the rest of your application files into the container
15
- COPY . .
 
 
16
 
17
- # Make port 7860 available to the world outside this container
18
- # This is the standard port for Hugging Face Spaces
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