Spaces:
Sleeping
Sleeping
Download button
Browse files- app.py +8 -2
- templates/map.html +19 -0
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException, Request, Form
|
| 2 |
-
from fastapi.responses import HTMLResponse
|
| 3 |
from fastapi.templating import Jinja2Templates
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
import random
|
|
@@ -125,7 +125,13 @@ def show_map(request: Request, start_date: str = None, end_date: str = None):
|
|
| 125 |
return templates.TemplateResponse("map.html", {"request": request, "map_html": map_html, "start_date": start_date, "end_date": end_date})
|
| 126 |
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
if __name__ == "__main__":
|
| 129 |
import uvicorn
|
| 130 |
-
uvicorn.run(app, host="0.0.0.0", port=
|
| 131 |
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException, Request, Form
|
| 2 |
+
from fastapi.responses import HTMLResponse, FileResponse
|
| 3 |
from fastapi.templating import Jinja2Templates
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
import random
|
|
|
|
| 125 |
return templates.TemplateResponse("map.html", {"request": request, "map_html": map_html, "start_date": start_date, "end_date": end_date})
|
| 126 |
|
| 127 |
|
| 128 |
+
@app.get("/download-csv")
|
| 129 |
+
async def download_csv():
|
| 130 |
+
if os.path.exists(CSV_FILE):
|
| 131 |
+
return FileResponse(CSV_FILE, filename="wifi_signals.csv")
|
| 132 |
+
raise HTTPException(status_code=404, detail="CSV file not found")
|
| 133 |
+
|
| 134 |
if __name__ == "__main__":
|
| 135 |
import uvicorn
|
| 136 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
| 137 |
|
templates/map.html
CHANGED
|
@@ -38,11 +38,27 @@
|
|
| 38 |
width: 80%;
|
| 39 |
display: flex;
|
| 40 |
justify-content: center;
|
|
|
|
| 41 |
}
|
| 42 |
.title {
|
| 43 |
margin-bottom: 20px;
|
| 44 |
text-align: center;
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</style>
|
| 47 |
</head>
|
| 48 |
<body>
|
|
@@ -64,6 +80,9 @@
|
|
| 64 |
<input type="date" id="end_date" name="end_date" class="form-control"
|
| 65 |
value="{{ end_date or '' }}">
|
| 66 |
</div>
|
|
|
|
|
|
|
|
|
|
| 67 |
</div>
|
| 68 |
</form>
|
| 69 |
<div id="map">
|
|
|
|
| 38 |
width: 80%;
|
| 39 |
display: flex;
|
| 40 |
justify-content: center;
|
| 41 |
+
align-items: center;
|
| 42 |
}
|
| 43 |
.title {
|
| 44 |
margin-bottom: 20px;
|
| 45 |
text-align: center;
|
| 46 |
}
|
| 47 |
+
.btn-download {
|
| 48 |
+
padding: 8px 15px;
|
| 49 |
+
font-size: 14px;
|
| 50 |
+
background-color: #007bff;
|
| 51 |
+
color: white;
|
| 52 |
+
border: none;
|
| 53 |
+
border-radius: 5px;
|
| 54 |
+
cursor: pointer;
|
| 55 |
+
transition: background-color 0.3s;
|
| 56 |
+
text-decoration: none;
|
| 57 |
+
margin-left: 15px;
|
| 58 |
+
}
|
| 59 |
+
.btn-download:hover {
|
| 60 |
+
background-color: #0056b3;
|
| 61 |
+
}
|
| 62 |
</style>
|
| 63 |
</head>
|
| 64 |
<body>
|
|
|
|
| 80 |
<input type="date" id="end_date" name="end_date" class="form-control"
|
| 81 |
value="{{ end_date or '' }}">
|
| 82 |
</div>
|
| 83 |
+
<div class="col-auto">
|
| 84 |
+
<a href="/download-csv" class="btn-download">Download CSV</a>
|
| 85 |
+
</div>
|
| 86 |
</div>
|
| 87 |
</form>
|
| 88 |
<div id="map">
|