Skip to content

Commit

Permalink
Adding Dijkstra download
Browse files Browse the repository at this point in the history
  • Loading branch information
thdfw committed Dec 20, 2024
1 parent ab17002 commit b612385
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
console.log(endUnixMilliseconds)

try {
const response = await fetch(`https://visualizer.electricity.works/plots`, {
const response = await fetch(`https://visualizer.electricity.works/download_excel`, {
// const response = await fetch('http://localhost:8000/download_excel', {
method: 'POST',
headers: {
Expand Down
19 changes: 1 addition & 18 deletions visualizer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,26 +508,9 @@ async def get_excel(request: DijkstraRequest):
# ------------------------------
# Generate interactive plots
# ------------------------------
from typing import Union

@app.post('/plots')
async def get_plots(request: Union[DataRequest, DijkstraRequest], apirequest: Request):

if isinstance(request, DijkstraRequest):
print("made it here")

download_excel(request.house_alias, request.time_ms)

if os.path.exists('result.xlsx'):
return FileResponse(
'result.xlsx',
media_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
headers={"Content-Disposition": "attachment; filename=file.xlsx"}
)
else:
return {"error": "File not found"}


async def get_plots(request: DataRequest, apirequest: Request):
request_start = time.time()
try:
async with async_timeout.timeout(TIMEOUT_SECONDS):
Expand Down

0 comments on commit b612385

Please sign in to comment.