saq1b's picture
Upload 2 files
79cbbff verified
FROM python:3.9-slim
WORKDIR /app
# Install necessary packages
RUN pip install --no-cache-dir flask gunicorn requests
# Copy the HTML file
COPY index.html /app/static/index.html
# Create a Flask app with API proxy
RUN echo 'from flask import Flask, redirect, jsonify\n\
import requests\n\
import json\n\
\n\
app = Flask(__name__, static_folder="static")\n\
\n\
@app.route("/")\n\
def index():\n\
return redirect("/static/index.html")\n\
\n\
@app.route("/api/trading-data")\n\
def trading_data():\n\
try:\n\
response = requests.get("https://badimo.nyc3.digitaloceanspaces.com/trade/frequency/snapshot/month/latest.json")\n\
return response.text, response.status_code\n\
except Exception as e:\n\
return jsonify({"error": str(e)}), 500\n\
\n\
if __name__ == "__main__":\n\
app.run(host="0.0.0.0", port=7860)\n\
' > /app/app.py
# Expose the port that HuggingFace Spaces expects
EXPOSE 7860
# Start the server
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]