Upload 2 files
Browse files- Dockerfile +14 -3
- index.html +3 -3
Dockerfile
CHANGED
|
@@ -3,19 +3,30 @@ FROM python:3.9-slim
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install necessary packages
|
| 6 |
-
RUN pip install --no-cache-dir flask gunicorn
|
| 7 |
|
| 8 |
# Copy the HTML file
|
| 9 |
COPY index.html /app/static/index.html
|
| 10 |
|
| 11 |
-
# Create a
|
| 12 |
-
RUN echo 'from flask import Flask, redirect\n\
|
|
|
|
|
|
|
|
|
|
| 13 |
app = Flask(__name__, static_folder="static")\n\
|
| 14 |
\n\
|
| 15 |
@app.route("/")\n\
|
| 16 |
def index():\n\
|
| 17 |
return redirect("/static/index.html")\n\
|
| 18 |
\n\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
if __name__ == "__main__":\n\
|
| 20 |
app.run(host="0.0.0.0", port=7860)\n\
|
| 21 |
' > /app/app.py
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install necessary packages
|
| 6 |
+
RUN pip install --no-cache-dir flask gunicorn requests
|
| 7 |
|
| 8 |
# Copy the HTML file
|
| 9 |
COPY index.html /app/static/index.html
|
| 10 |
|
| 11 |
+
# Create a Flask app with API proxy
|
| 12 |
+
RUN echo 'from flask import Flask, redirect, jsonify\n\
|
| 13 |
+
import requests\n\
|
| 14 |
+
import json\n\
|
| 15 |
+
\n\
|
| 16 |
app = Flask(__name__, static_folder="static")\n\
|
| 17 |
\n\
|
| 18 |
@app.route("/")\n\
|
| 19 |
def index():\n\
|
| 20 |
return redirect("/static/index.html")\n\
|
| 21 |
\n\
|
| 22 |
+
@app.route("/api/trading-data")\n\
|
| 23 |
+
def trading_data():\n\
|
| 24 |
+
try:\n\
|
| 25 |
+
response = requests.get("https://badimo.nyc3.digitaloceanspaces.com/trade/frequency/snapshot/month/latest.json")\n\
|
| 26 |
+
return response.text, response.status_code\n\
|
| 27 |
+
except Exception as e:\n\
|
| 28 |
+
return jsonify({"error": str(e)}), 500\n\
|
| 29 |
+
\n\
|
| 30 |
if __name__ == "__main__":\n\
|
| 31 |
app.run(host="0.0.0.0", port=7860)\n\
|
| 32 |
' > /app/app.py
|
index.html
CHANGED
|
@@ -136,8 +136,8 @@
|
|
| 136 |
</div>
|
| 137 |
|
| 138 |
<script>
|
| 139 |
-
// API URL
|
| 140 |
-
const API_URL = '
|
| 141 |
|
| 142 |
// Global data store
|
| 143 |
let tradeData = [];
|
|
@@ -165,7 +165,7 @@
|
|
| 165 |
console.error('Error fetching data:', error);
|
| 166 |
document.getElementById('data-table-body').innerHTML =
|
| 167 |
`<tr><td colspan="5" class="px-6 py-4 text-center text-red-500">
|
| 168 |
-
Error loading data. Please try again later.
|
| 169 |
</td></tr>`;
|
| 170 |
}
|
| 171 |
}
|
|
|
|
| 136 |
</div>
|
| 137 |
|
| 138 |
<script>
|
| 139 |
+
// API URL - updated to use our proxy endpoint
|
| 140 |
+
const API_URL = '/api/trading-data';
|
| 141 |
|
| 142 |
// Global data store
|
| 143 |
let tradeData = [];
|
|
|
|
| 165 |
console.error('Error fetching data:', error);
|
| 166 |
document.getElementById('data-table-body').innerHTML =
|
| 167 |
`<tr><td colspan="5" class="px-6 py-4 text-center text-red-500">
|
| 168 |
+
Error loading data: ${error.message}. Please try again later.
|
| 169 |
</td></tr>`;
|
| 170 |
}
|
| 171 |
}
|