Skip to content

Commit 70fdd10

Browse files
committed
Add Today button, remove redirect from /
1 parent a248208 commit 70fdd10

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

app/web.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,14 @@ def debug_db():
6262

6363
@app.get("/", response_class=HTMLResponse)
6464
def landing_page_today():
65-
"""Redirect to today's date."""
65+
"""Show today's filings."""
6666
from datetime import datetime
67-
today = datetime.now().strftime("%Y/%m/%d")
68-
from fastapi.responses import RedirectResponse
69-
return RedirectResponse(url=f"/{today}")
67+
now = datetime.now()
68+
return landing_page(now.year, now.month, now.day, is_today=True)
7069

7170

7271
@app.get("/{year:int}/{month:int}/{day:int}", response_class=HTMLResponse)
73-
def landing_page(year: int, month: int, day: int):
72+
def landing_page(year: int, month: int, day: int, is_today: bool = False):
7473
"""Show unique committees with large filings for a specific date."""
7574
import pandas as pd
7675
from datetime import datetime, timedelta
@@ -116,13 +115,14 @@ def landing_page(year: int, month: int, day: int):
116115
next_day = current + timedelta(days=1)
117116
prev_link = prev_day.strftime("/%Y/%m/%d")
118117
next_link = next_day.strftime("/%Y/%m/%d")
118+
today_link = '' if is_today else ' | <a href="/">Today</a>'
119119

120120
return f"""
121121
<html>
122122
<head><title>Sludgewire - {display_date}</title></head>
123123
<body>
124124
<h1>Filings >= $50k for {date_str}</h1>
125-
<p><a href="{prev_link}">&larr; Previous day</a> | <a href="{next_link}">Next day &rarr;</a></p>
125+
<p><a href="{prev_link}">&larr; Previous day</a> | <a href="{next_link}">Next day &rarr;</a>{today_link}</p>
126126
<form method="get" action="/go">
127127
<input type="date" name="date" value="{date_str}">
128128
<button type="submit">Go</button>

0 commit comments

Comments
 (0)