staalptkram/app.py

30 lines
654 B
Python
Raw Normal View History

2020-01-29 21:05:28 +00:00
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,
)