staalptkram/app.py
2020-01-29 22:05:28 +01:00

29 lines
654 B
Python

import requests
from datetime import datetime
from dateutil.parser import parse as dateparse
from pytz import reference
import flask
app = flask.Flask(__name__)
@app.route("/")
def index():
url = flask.request.args.get("apiurl", "")
if url:
json = requests.get(url).json()
listings = [
listing
for listing in json["listings"]
if listing["priorityProduct"] == "NONE"
]
else:
listings = []
return flask.render_template(
"marktplaats.html",
listings=listings,
dateparse=dateparse,
tz=reference.LocalTimezone(),
apiurl=url,
)