Spaces:
Running
Running
Fix static serving and Dockerfile formatting
Browse files- Dockerfile +1 -1
- app.py +7 -50
Dockerfile
CHANGED
|
@@ -14,7 +14,7 @@ COPY app.py .
|
|
| 14 |
COPY models.py .
|
| 15 |
COPY static/ ./static/
|
| 16 |
|
| 17 |
-
#
|
| 18 |
ENV PORT=7860
|
| 19 |
ENV PYTHONUNBUFFERED=1
|
| 20 |
|
|
|
|
| 14 |
COPY models.py .
|
| 15 |
COPY static/ ./static/
|
| 16 |
|
| 17 |
+
# Environment variables
|
| 18 |
ENV PORT=7860
|
| 19 |
ENV PYTHONUNBUFFERED=1
|
| 20 |
|
app.py
CHANGED
|
@@ -6,61 +6,18 @@ from flask import Flask, request, jsonify, send_from_directory
|
|
| 6 |
from flask_cors import CORS
|
| 7 |
from models import Capture, Species, ClosedSeason
|
| 8 |
|
| 9 |
-
app = Flask(__name__
|
| 10 |
CORS(app)
|
| 11 |
|
| 12 |
-
# Sample species data (in production, this would come from a database)
|
| 13 |
-
SPECIES_DATA = [
|
| 14 |
-
Species(
|
| 15 |
-
id='chillo',
|
| 16 |
-
commonName='Chillo',
|
| 17 |
-
scientificName='Lutjanus campechanus',
|
| 18 |
-
category='Fondo',
|
| 19 |
-
imageUrl='/assets/species/chillo.jpg',
|
| 20 |
-
protected=False,
|
| 21 |
-
closedSeason=ClosedSeason(
|
| 22 |
-
start='04-01',
|
| 23 |
-
end='06-30',
|
| 24 |
-
description='Veda de reproducci贸n'
|
| 25 |
-
)
|
| 26 |
-
),
|
| 27 |
-
Species(
|
| 28 |
-
id='dorado',
|
| 29 |
-
commonName='Dorado',
|
| 30 |
-
scientificName='Coryphaena hippurus',
|
| 31 |
-
category='Pel谩gico',
|
| 32 |
-
imageUrl='/assets/species/dorado.jpg',
|
| 33 |
-
protected=False
|
| 34 |
-
),
|
| 35 |
-
Species(
|
| 36 |
-
id='langosta',
|
| 37 |
-
commonName='Langosta del Caribe',
|
| 38 |
-
scientificName='Panulirus argus',
|
| 39 |
-
category='Invertebrado',
|
| 40 |
-
imageUrl='/assets/species/langosta.jpg',
|
| 41 |
-
protected=False,
|
| 42 |
-
closedSeason=ClosedSeason(
|
| 43 |
-
start='03-01',
|
| 44 |
-
end='06-30',
|
| 45 |
-
description='Veda de reproducci贸n'
|
| 46 |
-
)
|
| 47 |
-
),
|
| 48 |
-
]
|
| 49 |
-
|
| 50 |
-
# In-memory storage for captures (in production, use a database)
|
| 51 |
-
captures_storage = []
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
@app.before_request
|
| 55 |
-
def log_request_info():
|
| 56 |
-
"""Log incoming requests for debugging."""
|
| 57 |
-
app.logger.debug(f"Request: {request.method} {request.url}")
|
| 58 |
-
|
| 59 |
@app.route('/')
|
| 60 |
def index():
|
| 61 |
"""Serve the main HTML page."""
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
@app.route('/api/species', methods=['GET'])
|
|
|
|
| 6 |
from flask_cors import CORS
|
| 7 |
from models import Capture, Species, ClosedSeason
|
| 8 |
|
| 9 |
+
app = Flask(__name__)
|
| 10 |
CORS(app)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
@app.route('/')
|
| 13 |
def index():
|
| 14 |
"""Serve the main HTML page."""
|
| 15 |
+
return send_from_directory('static', 'index.html')
|
| 16 |
+
|
| 17 |
+
@app.route('/<path:path>')
|
| 18 |
+
def static_proxy(path):
|
| 19 |
+
"""Serve static files manually to ensure correct handling on HF Spaces."""
|
| 20 |
+
return send_from_directory('static', path)
|
| 21 |
|
| 22 |
|
| 23 |
@app.route('/api/species', methods=['GET'])
|