diff --git a/app.py b/app.py index 33b60d7..a67d112 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ import requests -from datetime import datetime +from datetime import datetime, timedelta from dateutil.parser import parse as dateparse from pytz import reference import flask @@ -9,6 +9,11 @@ app = flask.Flask(__name__) @app.route("/") def index(): + try: + refresh = int(flask.request.args.get("refresh", "300")) + except ValueError: + refresh = 300 + url = flask.request.args.get("apiurl", "") if url: json = requests.get(url).json() @@ -20,10 +25,14 @@ def index(): else: listings = [] + now = datetime.now() return flask.render_template( "marktplaats.html", listings=listings, + refresh=refresh, dateparse=dateparse, + now=now, + next=now + timedelta(seconds=refresh), tz=reference.LocalTimezone(), apiurl=url, ) diff --git a/templates/marktplaats.html b/templates/marktplaats.html index 1bc0e74..1a86da0 100644 --- a/templates/marktplaats.html +++ b/templates/marktplaats.html @@ -1,7 +1,11 @@ {##}
- + +