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, )